I'm creating a program that will help students track their marks, for that I need to web scrap the site where all our grades are stored. The idea was to automate the login and then there will be a separate script that will get the information that I need. I have trouble with automated login, because there is no input field and button ID. All I could find was names input fields and class for the button.
browser = webdriver.Chrome()
browser.get(("https://www.the-site.com/"))
usernameStr = "myUsername"
passwordStr = "myPassword"
username = browser.find_element("UserName")
username.send_keys(usernameStr)
password = browser.find_element("Password")
password.send_keys(passwordStr)
nextButton = browser.find_element("btn btn-default")
nextButton.click()
This is the error that I get:
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid locator
Here's the HTML for the input fields and button:
<form action="https://my.e-klase.lv?v=15" method="post" autocomplete="off">
<div class="form-group relative">
<input type="text" class="form-control" placeholder="Lietotājvārds"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false" name="UserName"
value="">
<div class="dummy-placeholder">Lietotājvārds</div>
</div>
<div class="form-group relative">
<input type="private" class="form-control upass"
placeholder="Parole"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
name="Password">
<div class="dummy-placeholder">Parole</div>
</div>
<button type="submit" class="btn btn-default">
<span class="progress"></span>
<span class="content">Pieslēgties</span>
</button>
</form>