Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99018

XHR request getting blocked and showing HTTP status code 405 with Python Selenium

$
0
0

Hi I am new to Selenium based automation. I am trying to load a page in Selenium with Python. But the website is blocking me.

They are sending XHR request to the site and redirecting based on the response. This works properly with manual process, i.e. manually putting in the ZIP code and selecting a pickup location. But when I try the same using Selenium driver its throwing 405 status code.

I went through few searches and they are asking to disable CORS in selenium, but that as well returns the same status code.

Is there any way I can handle CORS in selenium drivers?

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
# options.add_argument("--disable-web-security") <-- tried disabling CORS for selenium

driver = webdriver.Chrome("/path/to/chromedriver", chrome_options=options)

driver.get("https://www.peapod.com/")
enter_zip = driver.find_element_by_css_selector("#zipInput--top")
enter_zip.send_keys("60412")
submit_button = driver.find_element_by_css_selector("#guest-form--top > div.gateway-login_input-container > div > label > div.gateway-login_button-container > button")

submit_button.click()  

time.sleep(5)

# selecting the first location slot
location_selection = driver.find_element_by_css_selector(".location_select > button")
location_selection.click()  <-- this is the place it is getting blocked and throwing 405 status code

Is there any way to get past this or is there any JavaScript running which detects the browser type? Any help would be great.


Viewing all articles
Browse latest Browse all 99018

Trending Articles