有人请使用Cucumber和Web Driver帮助我进行Gmail登录测试自动化吗?
以下功能文件显示Gmail登录功能测试的方案:
功能:登录功能文件@硒设想:Gmail的登录方案测试给出导航到Gmail页面什么时候用户登录使用用户名为“用户名”和密码为“密码”然后主页应显示
现在,从此功能文件中,您可以使用WebDriver编写硒测试文件:
公共类Stepdefinition {WebDriver DR;@Given(“^导航到Gmail Page $”)public void navigate(){dr = new FirefoxDriver();Get博士(“ http://www.gmail.com”);} @when(“^用户登录使用用户名为\”(。*)\“和密码为\”(。。Dr.Findelement(by.xpath(“ //*[@ID ='passwd']”))。sendkeys(password);Dr.Findelement(by.xpath(“ //*[@ID ='signin']”))。click();Manage()。timeouts()。隐式任务(20,timeunit.seconds);} @then(“^应该显示为$”的主页)public void verifySuccessful(){字符串endive presenceText =“ gmail”;字符串MASETTEXT = dr.findelement(by.xpath(“ //*[@ID ='gbq1']/div/a/span”))。getText();Assert.AssertTrue(“登录不成功”,ExpectText.Equals(cutheText)); } }