Issue
I'm fairly new to selenium. I'm doing some tests with selenium for Python. As a an exercise, I need to lo access a web delivery service, and get a short listing of stores. However, I'm not able to get pass the first page. This is the url:
https://web.cornershopapp.com/stores-search/tech
In this site, I need to "click" on the "Cancelar" button, then enter a postal code (like 52989), then click on "Continuar" and that's it... I can then scrape the store listing that appears.
However, right from the start I get all sort of error messages in the console
I'm doing something like this:
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver', options=options)
driver.get(url)
soup = BeautifulSoup(driver.page_source, 'html.parser')
cancel_button = soup.find("span", text="Cancelar")
print(cancel_button)
But I can't find the cancel button, never mind clicking it, or entering a postal code in the next step. The resulting html doesn't seem to match the html I get when manually inspecting on Chrome.
Any suggestions on how to do this? Or, is there maybe a way to manually do this preliminar actions by myself, and then let the script scrape the stores after getting the listing?
The errors I get are:
[23968:11884:0603/100416.187:ERROR:device_event_log_impl.cc(214)] [10:04:16.188] USB: usb_device_handle_win.cc:1054 Failed to read descriptor from node connection: Uno de los dispositivos conectados al sistema no funciona. (0x1F)
[23968:11884:0603/100416.189:ERROR:device_event_log_impl.cc(214)] [10:04:16.189] USB: usb_device_handle_win.cc:1054 Failed to read descriptor from node connection: Uno de los dispositivos conectados al sistema no funciona. (0x1F)
[23968:11884:0603/100416.189:ERROR:device_event_log_impl.cc(214)] [10:04:16.189] USB: usb_device_handle_win.cc:1054 Failed to read descriptor from node connection: Uno de los dispositivos conectados al sistema no funciona. (0x1F)
Solution
I tried the below code :
executable_path = r"C:\\Users\\etc\\Desktop\\Selenium+Python\\chromedriver.exe"
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--enable-javascript")
driver = webdriver.Chrome(executable_path, options=options)
wait = WebDriverWait(driver, 10)
driver.get("https://web.cornershopapp.com/stores-search/tech")
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Cancel']/.."))).click()
select = Select(driver.find_element_by_tag_name('select'))
select.select_by_visible_text('México')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[placeholder='Zip code']"))).send_keys('52989')
wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Continue']/.."))).click()
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.