Reputation: 6835
I have a website with the following items:
<input type="text" style="width:230px;" name="email"></input>
and
<input type="password" style="width:230px;" name="password"></input>
With the following python code trying to set values (know username and password are set earlier in code):
Helper.getElementByxPath(mydriver,'//*[@name="email"]',username);
Helper.getElementByxPath(mydriver,'//*[@type="password"]',password);
And Helper.getElementByxPath is defined as:
def getElementByxPath(mydriver,xPath,valueString):
try:
a = mydriver.find_element_by_xpath(xPath);
a.send_keys(valueString);
return 1;
except:
return 0;
I get the following errors:
Unexpected error: <class 'selenium.common.exceptions.NoSuchElementException'>
Unexpected error: <class 'selenium.common.exceptions.NoSuchElementException'>
What am I possibly doing wrong here? Banging my head against a wall.
I am an idiot, my desired form was embedded in a frame. Within a frame.
Upvotes: 2
Views: 1997
Reputation: 9029
If your elements are in a frame
, you can use
driver.switch_to_frame(IDENTIFIER)
IDENTIFIER can be
- Frame name
- Frame webelement
- Frame index
API reference here: http://selenium-python.readthedocs.org/en/latest/api.html
Once you're finished in the frame, you can return to the top of the document as follows:
driver.switch_to_default_content()
Upvotes: 0