0

I'm trying to input a zipcode into a store website, and this works fine when I use webdriver.firefox() but does not work with PhantomJS. Instead I get an error:

NoSuchElementException: Message: {"errorMessage":"Unable to find element with id 'SL-map-search'"

This is the fairly simple code I'm using to generate the request. The set_window_size is only being used because other similar questions have suggested that this might fix the issue (it didn't).

driver = webdriver.PhantomJS()
# get address
driver.set_window_size(1920,1080)
driver.get("http://www.lowes.com/StoreLocatorDisplayView")

# select zipcode
element = driver.find_element(By.ID, 'SL-map-search')
element.send_keys(zipcode)
driver.find_element(By.ID, 'SL-map-search-submit').click()

Any help would be appreciated!

4
  • Have you tried this in Chrome? PhantomJS uses the same JS engine as Chrome. Which version of PhantomJS are you using? Or are you using GhostDriver? Also, what language is this; perhaps add the tag. Commented Jan 22, 2016 at 23:34
  • I'm using phantomjs v 2.0.0. I don't think I'm using ghostdriver. I'll check chrome! Commented Jan 22, 2016 at 23:46
  • It works with chrome, so I guess it just doesn't work with PhantomJS - any suggestions on how I should proceed? Commented Jan 23, 2016 at 0:02
  • Add waits. Start with a dumb Thread.sleep() (still don't know what language you are using!) and see if that changes anything. If yes, then start playing around with proper Selenium waits. Commented Jan 23, 2016 at 0:37

2 Answers 2

1

Wait for the element to be present:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "SL-map-search"))
)
element.send_keys(zipcode)
Sign up to request clarification or add additional context in comments.

Comments

0

the error was fixed when I upgraded to El Capitan.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.