angularjs – 无法使用非角度站点单击量角器中的按钮
发布时间:2020-12-17 17:24:42 所属栏目:安全 来源:网络整理
导读:我试图在发送密钥后单击登录按钮. 我可以填写电子邮件和密码字段,但由于某种原因,它不会单击登录按钮. 这是标记 section id="loginBox" h4 class="ban"Log in to your account/h4 p label for="inputEmailHandle"Email / Handle:/label input type="text" id
我试图在发送密钥后单击登录按钮.
我可以填写电子邮件和密码字段,但由于某种原因,它不会单击登录按钮. 这是标记 <section id="loginBox"> <h4 class="ban">Log in to your account</h4> <p> <label for="inputEmailHandle">Email / Handle:</label> <input type="text" id="inputEmailHandle" name="inputEmailHandle" value=""> </p> <p> <label for="inputPassword">Password:</label> <input id="inputPassword" type="password" name="inputPassword" autocomplete="off"> </p> <p> <label> </label> <button type="submit">Log In</button> <a href="/reset">forgot password?</a> </p> </section> 我尝试过几件事. 这是我的代码中的内容 it('should greet the named user',function () { // non angular site browser.ignoreSynchronization = true; browser.driver.get('http://example.com'); browser.driver.findElement(By.id('post')).click(); browser.driver.findElement(By.xpath("//input[@value='go']")).click(); browser.driver.findElement(By.css('.pickbutton')).click(); browser.driver.findElement(By.xpath("//input[@value='113']")).click(); browser.driver.findElement(By.xpath("//input[@value='3']")).click(); //click login button //this works sometime but fails a lot..non-consistent browser.driver.findElement(By.id('loginBox')).findElements(By.tagName('p')).then(function (el) { el[2].click(); }); }); 我也尝试了不同的其他东西,如下,没有任何成功. 1- browser.driver.findElement(By.xpath("//input[@type='button']")).click(); 2- browser.driver.findElement(By.id('loginBox a')).then(function (el) { el.click(); }); 这是堆栈 Using the selenium server at http://localhost:4444/wd/hub A Jasmine spec timed out. Resetting the WebDriver Control Flow. The last active task was: WebElement.click() at [object Object].webdriver.WebDriver.schedule (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:302:15) at [object Object].webdriver.WebElement.schedule_ (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:1665:23) at [object Object].webdriver.WebElement.click (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:1770:15) at /Library/WebServer/Documents/youman/test/spec/testlist.js:64:27 at /Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1582:15 at [object Object].webdriver.promise.ControlFlow.runInNewFrame_ (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1640:20) at notify (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:444:12) at notifyAll (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:422:7) at resolve (/Library/WebServer/Documents/youman/test/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:400:7) F Failures: 1) Craigslist automation should greet the named user Message: timeout: timed out after 10000 msec waiting for spec to complete Stacktrace: undefined Finished in 10.855 seconds 1 test,2 assertions,1 failure 任何帮助将不胜感激 解决方法
您应该能够使用xpath表达式访问该按钮,如下所示:
browser.driver.findElement(By.xpath("//button[text() = 'Log In']")).click(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |