I'm testing a web UI using Selenium in Python. I've come to a test case where a button should be redirected to another page after clicking.
However, every time the code executes without any exceptions but still the page is not being redirected. I'm sure that the button gets clicked correctly, as the button animation and mouse cursor change.
Here is the HTML source:
<div class="editorial-hero-banner--footer pb-35 pb-sm-0"><div class="SSOLogin__Container"><button type="button" class="btn btn-primary-blue">Sign in / Register</button></div></div>
<div class="SSOLogin__Container"><button type="button" class="btn btn-primary-blue">Sign in / Register</button></div>
<button type="button" class="btn btn-primary-blue">Sign in / Register</button>`
I tried with all possible options like:
- direct click method
- with XPATH and CSS_SELECTOR
- Javascript click method
- sleep for some time before clicking
- refresh and sleep before click
- WebDriverWait
But today while I was debugging tried with print(sign_in_occ.is_selected())
after click action where it returned as False
.
driver.refresh()
time.sleep(2)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.SSOLogin__Container > button.btn.btn-primary-blue"))).click()
sign_in = driver.find_element(By.CSS_SELECTOR, "button[class='btn btn-primary-blue']")
sign_in.click()
print(sign_in.is_selected())
# driver.execute_script("arguments[0].click();", sign_in)