login.php
calls the following function when submitted
<script type="text/javascript">
function validate(){
var res=confirm("Are you sure");
if(res)
return true;
else
return false;
}
</script>
I am trying to login through a python script using Selenium. When I click login the following script is called and I need to select 'yes' to login.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get("webpage/login.php")
username = browser.find_element_by_id("id")
password = browser.find_element_by_id("pass")
username.send_keys("username")
password.send_keys("password")
login_attempt = browser.find_element_by_xpath("//*[@type='submit']")
login_attempt.submit()
#I want to send yes to the `validate` function and the
#then then again do browser.get("webpage/home.php") to scrape info from a html tag
#print(login_attempt.submit())
I am relatively new to what I am trying to do .. suggestions are well received if there are better practices.