简体   繁体   English

如何用c#中的selenium2 webdriver点击特定坐标?

[英]How it is possible click on specific coordinates with selenium2 webdriver in c#?

I'm using Firefox with my test but there is a problem when it comes to clicking flash buttons. 我正在使用Firefox进行测试,但是在单击闪存按钮时出现问题。 I don't have access the source codes of flash elements, so i can't use flash-selenium or anything similar for test. 我没有访问flash元素的源代码,所以我不能使用flash-selenium或类似的东西进行测试。

Currently my solution is getting a screenshot with windows api, and processing the screenshot and defining the button coordinates which I'm supposed to be click on it, then again with windows api clicking on the coordinates. 目前我的解决方案是使用windows api获取屏幕截图,并处理屏幕截图并定义我应该点击它的按钮坐标,然后再次使用windows api点击坐标。

But in this way, i can't use my computer for anything else and i must wait for interacting pc unlike webdriver's own functions. 但通过这种方式,我无法使用我的电脑做任何其他事情,我必须等待与webdriver自己的功能不同的交互式电脑。

I'm trying to do getting a screenshot on Firefox page with webdriver (it's done actually), and getting in that screenshot the area coordinates of flash button and clicking on it without element based because when i use for checking if it's possible selenium ide, it can't click with functions like clickat or i am doing something wrong. 我正在尝试使用webdriver在Firefox页面上获取屏幕截图(实际上已完成),并在屏幕截图中获取flash按钮的区域坐标并单击它而不使用基于元素的因为当我用于检查是否可能是selenium ide时,它不能点击像clickat这样的功能,或者我做错了什么。

In Selenium 2 you will be able to simulate moving the mouse to specified co-ordinates and click using the MoveToOffsetAction in the Advanced User Interactions API. 在Selenium 2中,您将能够模拟将鼠标移动到指定的坐标,并使用高级用户交互API中的MoveToOffsetAction进行单击。 This is currently still in development and not yet supported in the Firefox or Internet Explorer drivers. 目前这仍处于开发阶段,但Firefox或Internet Explorer驱动程序尚不支持。

More details of the Advanced Users Interactions API can be found on the project's official wiki page: http://code.google.com/p/selenium/wiki/AdvancedUserInteractions 有关Advanced Users Interactions API的更多详细信息,请参见项目的官方维基页面: http//code.google.com/p/selenium/wiki/AdvancedUserInteractions

You can do it in Java as following: 您可以使用Java执行以下操作:

Actions uploadbtn = new Actions(driver);  
uploadbtn.moveToElement(addfile, 518, 558).click().build().perform();

where X co-ordinates=518
and Y Co-ordinates=558

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM