1

I'm trying to automate some tedious copy / paste I do monthly from my bank's online service via Selenium and Python 3. Unfortunately, I can't get Selenium to click the log-in link.

It's the blue continue button at https://www1.bmo.com/onlinebanking/cgi-bin/netbnx/NBmain?product=5.

Strangely, when I try to click that link manually in the browser launched by Selenium, it doesn't work either - whereas it does work in a browser I launch manually.

I suspect the issue is that the bank's website is smart enough to detect that I'm automating the browser activity. Is there any way to get around that?

If not, could it be something else?

I've tried using Chrome and Firefox - to no avail. I'm using a 64 bit Windows 10 machine with Chrome 73.0.3683.103 and Firefox 66.0.

Relevant code is below.

#websites and log in information
bmo_login_path = 'https://www1.bmo.com/onlinebanking/cgi-bin/netbnx/NBmain?product=5'
bmo_un = 'fake_user_name'
bmo_pw = 'fake_password'

#Selenium setup
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
chrome_driver_path = 'C:\\Path\\To\\Driver\\chromedriver.exe'
gecko_driver_path = 'C:\\Path\\To\\Driver\\geckodriver.exe'
browswer_bmo = webdriver.Firefox(executable_path = gecko_driver_path)
#browswer_bmo = webdriver.Chrome(executable_path = chrome_driver_path)

#log into BMO
browswer_bmo.get(bmo_login_path)
time.sleep(5)
browswer_bmo.find_element_by_id('siBankCard').send_keys(bmo_un)
browswer_bmo.find_element_by_id('regSignInPassword').send_keys(bmo_pw)
browswer_bmo.find_element_by_id('btnBankCardContinueNoCache1').click()

Sending the keys works perfectly. I may actually have the wrong element ID (I was trying to test that in Chrome when I realized I couldn't click the link manually) - but I think the bigger issue is that I can't manually click the link in the browser launched by Selenium. Thank you for any ideas.

EDIT

This is a screenshot that I get of all I get when I try to click the continue button.

Continue button not loading.

Ultimately the error message I get in my IDE (Jupyter Notebook) is:

TimeoutException: Message: timeout
  (Session info: chrome=74.0.3729.108)
  (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64)
PKB
  • 321
  • 1
  • 11
  • Thank you very much. I've had to put this on hold because I'm travelling, but as soon as I'm back home I'll revive my efforts and try the Selenium IDE and Kantu. – PKB May 01 '19 at 17:04

2 Answers2

-1

To click on the button with text as Continue you can fill up the Card Number and Password field inducing WebDriverWait for the element_to_be_clickable() and you can use the following solution:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
    options = webdriver.ChromeOptions()
    options.add_argument('start-maximized')
    options.add_argument('disable-infobars')
    options.add_argument('--disable-extensions')
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get('https://www1.bmo.com/onlinebanking/cgi-bin/netbnx/NBmain?product=5')
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.dijitReset.dijitInputInner#siBankCard[name='FBC_Number']"))).send_keys("1234567890112233")
    driver.find_element_by_css_selector("input.dijitReset.dijitInputInner#regSignInPassword[name='FBC_Password']").send_keys("fake_password")
    driver.find_element_by_css_selector("span.dijitReset.dijitInline.dijitIcon.dijitNoIcon").click()
    # driver.quit()
    
  • Browser Snapshot:

Continue

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you! Unfortunately, when I try using your code wholesale, I still get an unclickable button (programmatically or manually). Could it be because this morning I thoughtlessly updated my Chrome to 74.0.3729.108 when it gave me the option? – PKB Apr 28 '19 at 17:17
  • @PKB Not sure why you would get **unclickable button** but with compatible versions of _ChromeDriver_ and _Chrome_ this code block works just perfecto. – undetected Selenium Apr 28 '19 at 18:04
  • I would think so too. I'm still able to get the code to run as far as far as populating the fields, but the page just refuses to load. Selenium gives me a timeout, but Chrome seems to just spin indefinitely (I've let it spin 20 odd minutes without a timeout). I admit I'm a beginner so I'm going to try to parse the HTML and figure out what you're doing with CSS_SELECTOR and maybe that will give me ideas. Thank you again. – PKB Apr 28 '19 at 18:40
  • As _a beginner_ can you please copy-paste the code from my answer and get back to me with the status using compatible versions of _ChromeDriver_ and _Chrome_? – undetected Selenium Apr 28 '19 at 18:44
  • Thank you, I tried again. I've edited my post with the screenshot of what I get use your exact code. All i changed is the path to the updated Chromedriver. – PKB Apr 29 '19 at 16:56
-1

I was able to fix this issue and solve the problem by adding the following line below the options variables. This disables the chrome check for automation. I used the whole sale code and then added the following line in the correct location before starting the driver.

options.add_experimental_option("excludeSwitches", ['enable-automation'])

ref: https://help.applitools.com/hc/en-us/articles/360007189411--Chrome-is-being-controlled-by-automated-test-software-notification

jedimonk
  • 27
  • 1
  • 6