简体   繁体   English

jquery命令在控制台上成功运行,但是在添加click()时不起作用,但也未显示任何错误

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

相关问题 代码将无法运行,也不会显示任何错误 - Code won't run and does not show any errors either .click()在页面加载时不起作用,但在控制台中工作 - .click() doesn't work on page load but works in console javascript中的click()无法正常运行,但在控制台中可以正常运行 - click() in javascript doesn't work but in console it works fine jQuery:on('click',…)不起作用,on('mouseenter',…)起作用 - jquery: on('click', …) doesn't work, on('mouseenter', …) does jQuery on(click)不起作用,但on(hover)起作用 - jquery on(click) doesn't work but on(hover) does 用jQuery替换链接文本不起作用,控制台中没有错误 - Replacing link text with jQuery doesn't work, no errors in console 当使用 F5 重新加载 web jQuery 进度条不起作用,我的 web 也没有显示任何内容 - When using F5 reload web jQuery progress bar didn't work and my web didn't show any content either jQuery Click-在第1页加载时不起作用,但是在重新加载页面时起作用 - jQuery Click - Doesn't work when page 1st loaded, but works if page is reloaded exec命令不适用于添加的变量,但是可以在不添加变量的情况下使用 - exec command doesn't work with variables added, but works without variables variables added 我的 javascript 代码不起作用,但在控制台中执行时它起作用 - My javascript code doesn't work, but when it is executed in the console it works
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM