[英]Can we use Web driver to test https:// sites? I am trying to work on gmail.com and it doesn't work
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class MyFirstSelTest {
public static void main(String args[]){
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.gmail.com/");
WebElement un = driver.findElement(By.id("Email"));
WebElement pwd = driver.findElement(By.id("Passwd"));
WebElement submitBtn = driver.findElement(By.id("wp-signIn"));
un.sendKeys("ValidUsername");
pwd.sendKeys("ValidPassword");
submitBtn.click();
driver.quit();
}
}
Gmail home page is opened, but no data is entered into username and password field. Gmail主页已打开,但未在用户名和密码字段中输入任何数据。 Can some one please help me as to what we need to do for this?
有人可以帮我解决一下我们需要做些什么吗?
Thanks, Mike 谢谢,迈克
For reasons I do not get the problem is the submit button : 我没有遇到问题的原因是提交按钮:
Try to replace with : WebElement submitBtn = driver.findElement(By.id("signIn"));
尝试替换为:
WebElement submitBtn = driver.findElement(By.id("signIn"));
You didn't identify the submit button correctly. 您没有正确识别提交按钮。
Try with below locators. 尝试使用以下定位器。
driver.findElement(By.cssSelector("div.email-div>input[id='Email']")).sendKeys(Email);
driver.findElement(By.cssSelector("div.passwd-div>input[id='Passwd']")).sendKeys(Email);
driver.findElement(By.id("signIn")).click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.