0

I am trying to use selenium to click certain buttons within the bank of america simulator, but the buttons don't seem to ever click. No new link is reached, which is something I haven't encountered before.

https://message.bankofamerica.com/onlinebanking_demo/OLB_Simulator/

I want to click "Sign in options" and then click "Sign in: Recognized device"

I tried using selenium to click the button and I get no error. Nothing happens at all and the program continues, so I know it's not an issue with not finding the button. My current code is as follows:

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get('https://message.bankofamerica.com/onlinebanking_demo/OLB_Simulator/')

sleep(3)

login_button = driver.find_element("id", "landing_sign")
driver.execute_script("arguments[0].click();", login_button);
Ryan Reid
  • 11
  • 2

2 Answers2

0

This code worked fine for me.

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

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get('https://message.bankofamerica.com/onlinebanking_demo/OLB_Simulator/')
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.ID, "landing_sign")).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[aria-labelledby='signInOpt3']")).click()

NOTE: Using sleep is a bad practice, use WebDriverWait and wait for the specific state you need instead.

JeffC
  • 22,180
  • 5
  • 32
  • 55
0

To click on the clickable elements you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategies:

  • Code block:

    driver.get('https://message.bankofamerica.com/onlinebanking_demo/OLB_Simulator/')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#landing_sign"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[href='/onlinebanking_demo/OLB_Simulator/SignIn/recognized']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

recognized

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352