2

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.

2
  • The elements could be in a frame or iframe. If the elements are in a frame/iframe, you can use switch_to_frame(IDENTIFIER), where IDENTIFIER is the frame name, the frame webelement, or the index of the frame. Or it could be that the elements are loading slowly or after the page completes loading. Commented May 16, 2014 at 0:43
  • thanks will look into switch_to_frame Commented May 16, 2014 at 0:47

1 Answer 1

0

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.