如何使用硒单击工具栏项目? [英] How to click on Toolbar Item with selenium?

查看:31
本文介绍了如何使用硒单击工具栏项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网页包含一个带有一些文本的按钮,例如测试".这个按钮实际上是一个工具栏元素.( class ="tbButton" id="id",text="Test") 并在按下时重定向到某个表.当尝试使用以下点击方法时

Web page contain a button with some text for example "Test". This button actually is a toolbar element. ( class ="tbButton" id="id",text="Test") and redirects to a certain table when press on it. When try to use the following click methods

selenium.click("id");
   selenium.doubleClick("id");
   selenium.click("//*[text()='Test'and contains(@class, 'tbButton')] ");

按钮没有反应任何人都可以展示一种能够解决问题的替代方法

the button does not react Could enybody show an alternative methods that is able to resolve a problem

推荐答案

如果不了解您正在测试的页面的实际内容,就很难确切地知道问题出在哪里.网上有没有工具栏的例子?

It's hard to know exactly what the problem is without knowing more about the actual contents of the page you are testing. Is there an example of the toolbar online somewhere?

使用现代界面,使用 Selenium 定位元素并不总是一门精确的科学.以下是一些建议:

With modern interfaces, locating elements with Selenium is not always an exact science. Here are a few suggestions:

  • 使用现代界面,您经常会发现 DOM 正在被操纵,因此当您到达 click() 时,您使用的标识符可能不再有效.使用 Firebug 检查您是否拥有正确的元素.

  • With modern interfaces you often find that the DOM is being manipulated, so it is possible that the identifier you are using is no longer valid by the time you get to your click(). Use Firebug to check that you have the correct element.

单击元素的父元素通常会有所帮助,例如 div 或父表格单元格.再次使用 FireBug 来尝试工具栏按钮附近的一些其他元素.或者,Firebug 有时会显示该元素包含其他元素.您可能会更幸运地将目标更改为包含的元素.

Often it helps to click on the parent of the element, such as a div or the parent table cell. Again, use FireBug, to try some other elements near your toolbar button. Alternatively, Firebug sometimes reveals that the element contains other elements. You might have more luck changing the target to a contained element instead.

有时您必须尝试一些替代操作.例如,某些控件响应 mouseDown() 后跟一个 mouseUp(),而不响应 click().同样,您通常可以通过使用 Firebug 查看源代码来获得提示.

Sometimes you have to play around with some of the alternative actions. For instance, some controls respond to a mouseDown() followed by a mouseUp(), but not to a click(). Again you can often get hints from looking at the source with Firebug.

这篇关于如何使用硒单击工具栏项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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