0
votes

Hi for some reason I am unable to login into zillow. I cant find the email or password input fields to send keys to. The script was working but now it cannot locate the element?

I am passing a driver object with the URL:

driver = webdriver.Firefox()
driver = driver.get("http://www.zillow.com/")
time.sleep(2)
driver.find_element_by_id("login_opener").click()
time.sleep(5)
try:
    driver.find_element_by_id("email").send_keys(username)
    driver.find_element_by_id("password").send_keys(password)
    time.sleep(2)
    driver.find_element_by_id("loginSubmit").click()
except:
    try:
        time.sleep(4)
        driver.find_element_by_id("email").send_keys(username)
        driver.find_element_by_id("password").send_keys(password)
        time.sleep(2)
        driver.find_element_by_id("loginSubmit").click()
    except:
        pdb.set_trace()
        print "Cant login"

NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"email"} Stacktrace: at FirefoxDriver.prototype.findElementInternal_ (file:///var/folders/b1/r8rn2dg17k93wnn4kw_fpyf40000gn/T/tmpKjj1hV/extensions/[email protected]/components/driver-component.js:10271) at FirefoxDriver.prototype.findElement (file:///var/folders/b1/r8rn2dg17k93wnn4kw_fpyf40000gn/T/tmpKjj1hV/extensions/[email protected]/components/driver-component.js:10280) at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/b1/r8rn2dg17k93wnn4kw_fpyf40000gn/T/tmpKjj1hV/extensions/[email protected]/components/command-processor.js:12274) at DelayedCommand.prototype.executeInternal_ (file:///var/folders/b1/r8rn2dg17k93wnn4kw_fpyf40000gn/T/tmpKjj1hV/extensions/[email protected]/components/command-processor.js:12279) at DelayedCommand.prototype.execute/< (file:///var/folders/b1/r8rn2dg17k93wnn4kw_fpyf40000gn/T/tmpKjj1hV/extensions/[email protected]/components/command-processor.js:12221)

1
What is the error trace?David Zemens
@DavidZemens posted.Test Dev

1 Answers

2
votes

The login form is located inside an iframe. You have to switch into it's context:

driver.find_element_by_id("login_opener").click()
time.sleep(5)  # TODO: replace with an Explicit Wait

frame = driver.find_element_by_css_selector("iframe[src*=InlineLogin]")
driver.switch_to.frame(frame)

# now while you are in the iframe, search for the input

Works for me.