I'm currently using HtmlUnitDriver, and while I am able to set the username, I keep getting an error that Selenium could not find the password field. I am using JavascriptExecutor to set these values inside the PayPal sandbox form, but I'm still unable to get past the password step.
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME)
JavascriptExecutor executor = (JavascriptExecutor)driver
driver.setJavascriptEnabled(true)
driver.get(url)
log.debug "setting username"
Thread.sleep(5000)
if(driver.findElement(By.xpath("//*[@id='email']")).displayed){
executor.executeScript("document.getElementById('email').value = 'email';")
log.debug "Username was set"
} else {
log.debug "We never set the username!"
}
if(driver.findElement(By.xpath("//*[@id='password']")).displayed){
executor.executeScript("document.getElementById('password').value='password';")
} else {
log.debug "We never set the password."
}
I understand that I am setting sleeps in there, and that's bad practice for Selenium testing, but I'm pretty much at my wits end here. The url in that case is the link to express checkout, which is something like this: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#################
Any help would be greatly appreciated!