I'm trying to create a script to login into my trading account.
Currently, I am able to click onto the page to login, however the script is unable to locate the username or password input.
I've put a copy of the script below.
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.anz.com.au/personal/investing-super/online-share-investing/")
## Clicking on the login button
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.LINK_TEXT, "Log in"))
)
element.click()
print("success in clicking button")
except:
print("login button has failed")
driver.quit()
## Entering in credentials
driver.switch_to.frame(driver.find_element_by_tag_name('iframe'))
driver.find_element_by_xpath("//*[@id = 'username']").send_keys("123456")
driver.find_element_by_id("password").send_keys("hello")
# try:
# # print("switch success")
# element = WebDriverWait(driver, 10).until(
# EC.presence_of_element_located((By.ID, "username"))
# )
# print("finding element success")
# element.click()
# element.send_keys("blanklogin")
# except:
# print("credentials login has failed")
# driver.quit()
I've tried using both xPath + ID to search but with no luck:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id = 'username']"}
I've also notice that some other users have had problems with iframe's hence tried to include that in the code with no luck. I've also tried clicking on the box first ( in the try-except statement ) but that didn't work either.
Would strongly appreciate any input.
Thanks!!
EDIT: Attaching a screenshot of the HTML in question: html