2

I'm trying to write a simple program using Python 2.7 and Selenium to automate checking my Presidents Choice MasterCard balance. However, I can't figure out how to deal with the hidden 'Go' button. My code works fine up to that point.

Check Banking

import time
import os
import subprocess
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import ui

user_id = raw_input('Enter your account number')
#password = raw_input('Enter your password')

driver = webdriver.Chrome()  # Optional argument, if not specified will search path.

def regular():

    site = driver.get('https://www.pcfinancial.ca/');
                                         
    sign_in_to = driver.find_element_by_xpath('//*[@id="lnkSignInOp"]').click()
    select = driver.find_element_by_xpath('//*[@id="PCM"]/a').click()
    select2 = driver.find_element_by_xpath('//*[@id="PCM"]/a').click()

    go = driver.find_element_by_xpath('//*[@id="ctl00_uscHeader_btnRegister"]').click()

                                  
                                     
regular()
2
  • what means hidden ? do you have to scroll page to see it ? There are example with javascript code which can scroll page to button. Commented Dec 9, 2017 at 2:06
  • your last xpath seems incorrect. I can't find it on page. I think you search wrong element. Button Go has different id. Maybe after you click Go you get page with element id="ctl00_uscHeader_btnRegister Commented Dec 9, 2017 at 2:14

1 Answer 1

1

You are doing it in a wrong way. You are clicking the PCM and after that PCM you are Clicking PCM again. Although you can select one option from drop down list.

Your go button id is also wrong.

your code should be look like below ---

import time
import os
import subprocess
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import ui

user_id = raw_input('Enter your account number')
#password = raw_input('Enter your password')

driver = webdriver.Chrome()  # Optional argument, if not specified will search path.

def regular():

    site = driver.get('https://www.pcfinancial.ca/');

    sign_in_to = driver.find_element_by_xpath('//*[@id="lnkSignInOp"]').click()
    select = driver.find_element_by_xpath('//*[@id="PCM"]/a').click()


    go = driver.find_element_by_xpath('//*[@id="util-go"]').click()



regular()

IF you want to select PC points option then click on below element instead of Pc Master card

select2 = driver.find_element_by_xpath('//*[@id="PCP"]/a').click()
Sign up to request clarification or add additional context in comments.

6 Comments

Mahmud, thanks, your code fixed my problem for me. Much appreciated.
@Mike Great News !!! Can you Accept the Answer by clicking on the tick mark beside my Answer, just below vote Up/Down arrows, so the tick mark turns Green? Thanks
Mahmud, thanks, but I'm still getting errors with the following code: select = driver.find_element_by_xpath('//*[@id="PCM"]/a').click() go = ui.Select(driver.find_element_by_xpath('//*[@id="util-go"]').click()) WebDriverException: Message: unknown error: Element is not clickable at point (946, 47)
@Mike above code and xpath is absolutely perfect. just put a wait before clicking pc master and after clicking pc masters button before the go button. for example put time.sleep(5) before click PCM and after click PCM time.sleep(5)
Thanks. Once more I got stumped by failing to include time.sleep(5), which instantly solved my problem. Thanks again for your help!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.