I'm trying to auto login to a website. When the main page loads, It has a login button, which brings up the login form with username and password forms.
The button is inside a div element with an id equal to 'loginbox':
<div class="col-md-6 col-sm-4 text-right" id="loginbox">
<div class="row">
<div class="col-md-12 margin-bottom-10">
<button type="button" class="btn btnlogin" data-toggle="modal" data-
target="#loginDiv">
This is my code for finding the button, and then clicking it:
driver = webdriver.Firefox()
driver.get('websiteURL')
wait = WebDriverWait(driver, 10)
driver.find_element_by_xpath("//div[@id='loginbox']/button[1]").click()
When I run the code, I get this error:
"Unable to locate element: //div[@id='loginbox']/button[1]"
How should I locate this button?
This is the rest of my code for filling username and password inputs:
username = wait.until(EC.visibility_of_element_located((By.NAME, "FRMLoginUname")))
username.clear()
username.send_keys('UserName')
password = wait.until(EC.visibility_of_element_located((By.NAME, "FRMLoginPassword")))
password.clear()
password.send_keys('Password')