I am trying to write a program that allows me to auto login on a cloud service. The fields corrensponding to the username and password in the HTML are:
<div class="formRow">
<input type="text" name="emailOrUsername" ng-model="emailOrUsername" panono-text-box=
"{ "placeholder": "states.account.logIn.emailOrUsername", "required": true }
" panono-focus="" class="ng-pristine ng-valid panonoTextBox ng-touched" placeholder=
"Email or username *" spellcheck="false">
</div>
<div class="formRow">
<input type="password" name="password" ng-model="password" panono-text-box=
"{ "placeholder": "states.account.logIn.password", "required": true }
" class="ng-pristine ng-untouched ng-valid panonoTextBox" placeholder="Password *" spellcheck="false">
</div>
The code I have written is:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
usernameStr = "my_username"
passwordStr = "my_password"
browser = webdriver.Chrome()
browser.get("https://mywebsite.com")
wait = WebDriverWait(browser, 10)
if wait:
username = browser.find_element_by_name("emailOrUsername");
password = browser.find_element_by_name("password")
username.send_keys(usernameStr)
username.send_keys(usernameStr)
I get this error message.
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"emailOrUsername"}
Looks like you need to find those elements
by name
instead ofby id