[英]jquery command works successfully on console but does not work when click() is added but doesn't show any errors either
Go to this page : CNET Login 转到此页面: CNET登录
Using jquery I'm trying to click on the facebook button that's just above the Google+ button. 我试图使用jquery单击位于Google+按钮上方的facebook按钮。 (see the three buttons on the left)
(请参阅左侧的三个按钮)
On the Chrome developer console, I type in the following and it works : 在Chrome开发者控制台上,我输入以下内容,它可以正常工作:
$('#rbContent > div > form > div.social-authenticate > ul > li.social-site.facebook > span')
I add in click() like so : 我像这样添加click():
$('#rbContent > div > form > div.social-authenticate > ul > li.social-site.facebook > span').click()
and the console shows it is successful (or at least looks like it) but the nothing happens on the browser itself. 并且控制台显示它成功(或至少看起来像它),但是浏览器本身什么也没有发生。 It's as if the click was not triggered at all.
好像完全没有触发点击。
Screenshot of both those options here : 这两个选项的屏幕截图:
Found the answer. 找到了答案。 Had to workaround it.
必须解决它。 Here's the java version of the implementation for the google button (not fb).
这是google按钮(不是fb)实现的Java版本。 (you can do the same thing in js as well)
(您也可以在js中执行相同的操作)
wait.until(ExpectedConditions.presenceOfElementLocated((By.xpath("//* [@id='rbContent']/div/form/div[1]/ul/li[1]/span"))));
WebElement googleLogin = driver.findElement (By.xpath("//*[@id='rbContent']/div/form/div[1]/ul/li[1]/span")) ;
Actions builder = new Actions(driver);
builder.moveToElement(googleLogin).click().perform();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.