Selenium.click不适用于某些锚元素 [英] Selenium.click not working on some anchor elements

查看:127
本文介绍了Selenium.click不适用于某些锚元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近修改了正在运行的应用程序,并引入了新的JQuery日历的一部分。我需要点击日历中的链接来选择时间和日期。但是,Selenium.click不起作用。该命令得到执行,但屏幕上没有任何反应。

为了检查我的XPATH / CSS定位器(我尝试了两种)是否正确,我添加了selenium.getText(locator)和selenium.highlight(locator)命令。两人都工作!没有问题。它只有没有工作的点击。

在检查Firebug时,我可以看到我试图点击的div是灰色状态。这是否意味着元素被禁用?看下面的萤火虫的截图。

我也尝试在Selenium IDE中运行相同的命令。在IDE中,有时起作用。



我正在使用Selenium 1.xx运行此测试。

更新:


作为
调试的一部分。在测试运行期间,I
在浏览器
中打开Selenium IDE,以便它记录
发生的操作。 IDE记录了所有操作
直到该点击。但是当执行单击
命令时,我看不到
任何东西在IDE中。任何想法的家伙,
会是什么原因?

有没有人遇到类似的问题?任何帮助将不胜感激!!!

解决方案

尝试 selenium.fireEvent(locater,'click'),或者使用与浏览器更紧密集成的Selenium 2。 / p>

您可能会遇到与其他人相同的问题,例如。 //www.google.com/security/selenium-clicks-not-working-with-gwt\"> Selenium点击不能与GWT合作



使用Selenium'点击'非输入或非输入 - 控制元素



它似乎与使用Javascript添加的点击事件有关。



已编辑



我不知道您是否使用相同的日历实施,但我发现fullcalendar.js jQuery替换米ouseover事件,你必须先触发它。我得到它使用

  selenium.runScript(jQuery(\a:contains('+ NEW_EVENT_NAME $ b ('''');'trigger('mouseover'); jQuery(\a:contains('
+ NEW_EVENT_NAME +'')\)。 );


The application that am working on was recently revamped and as part of that a new JQuery calendar was introduced. I need to click on a link in the calendar to select the time and date. However, Selenium.click is not working. The command gets executed, but nothing happens on the screen.

To check whether my XPATH/CSS locator (I tried both) is correct, I added selenium.getText(locator) and selenium.highlight(locator) commands. Both worked!. No issues in that. Its ONLY the click that is not working.

Upon checking in firebug, I could see that the div on which I am trying to click is kind of grayed out state. Does it meant that element is disabled? See the screenshot of the firebug below.

I also tried to run the same command in Selenium IDE. In IDE this works "sometimes".

I am running this test using Selenium 1.xx.

UPDATE:

I did one more thing as part of debugging. During the test run, I opened the Selenium IDE in the browser so that it records what actions are happening. IDE recorded all actions till this click. But I couldn't see anything in the IDE when the click command was executed. Any idea guys, what would be cause?

Has anyone faced a similar issue before? Any help would be appreciated!!!

解决方案

Try selenium.fireEvent(locater, 'click'), or using Selenium 2 which is more tightly integrated with the browser.

You may be having the same problem as some other people, eg.

Selenium clicks not working with GWT

Using Selenium to 'click' on non-input or non-control elements

It seems to be related to click events which are added with Javascript.

Edited

I don't know if you're using the same calendar implementation, but I discovered that the fullcalendar.js jQuery one replaces the mouseover event, and you have to trigger that first. I got it to work using

selenium.runScript("jQuery(\"a:contains('" + NEW_EVENT_NAME
        + "')\").trigger('mouseover');jQuery(\"a:contains('"
        + NEW_EVENT_NAME + "')\").trigger('click')");

这篇关于Selenium.click不适用于某些锚元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆