简体   繁体   English

我们可以使用Web驱动程序来测试https:// sites吗? 我正在尝试在gmail.com上工作,但它不起作用

[英]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.

相关问题 我正在尝试在我的 Cucumber 跑步者中使用标签,但不起作用。 我是 Cucumber 的新手 - I am trying use tag in my Cucumber runner but doesn't work. I am new to Cucumber 浏览器中的证书验证(具体情况:https://gmail.com) - Certificate validation in browsers (specific case: https://gmail.com) 为什么https:// username:password@example.com不起作用? - Why doesn't https://username:password@example.com work? 尝试使用 SharedPrefrences 但它不起作用 - Trying to use SharedPrefrences and it doesn't work 我的Java套接字不适用于Google.com,但可以与其他网站一起使用 - My Java Socket doesn't work with Google.com but does with other sites 我正在尝试将拦截器与mvc注释驱动一起添加到spring中,以下内容应该起作用,但是不是吗? - I am trying to add an Interceptor to spring along with mvc annotation driven, the following should work, but doesn't? 我正在尝试在 Java 中创建一个 SEIR model,但它不适用于所有变量 - I am trying to create a SEIR model in Java, but it doesn't work well with all the variables 我试图做一个if语句,如果Edittext(number)大于一个int值,但是它不起作用 - I am trying to make an if statement where it looks if the Edittext(number) is greater than an int value but it doesn't work CarbonCopy到Gmail地址似乎不起作用 - CarbonCopy to a gmail address doesn't seem to work 我试图只从用户那里获取一个字符串,任何人都可以指导我为什么我的代码不起作用。 它甚至接受 integer 作为字符串值 - I am trying to get only a string from a user, can any one please guide me why my code doesn't work. it even accepts the integer as String value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM