Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在SeleniumWebDriver中基于图像单击_C#_Selenium_Bitmap_Selenium Webdriver - Fatal编程技术网

C# 如何在SeleniumWebDriver中基于图像单击

C# 如何在SeleniumWebDriver中基于图像单击,c#,selenium,bitmap,selenium-webdriver,C#,Selenium,Bitmap,Selenium Webdriver,在Selenium webdriver C#winform Firefox中,如何单击文档中的图像?这可能吗 让我解释一下 我的桌面上有一个名为watch.jpg的图像,我希望它在FireFox实例中找到该图像,并在该图像可见时单击该图像。那么按照这个顺序, 查找图像 移到图像 单击图像 谢谢你的帮助 我试过这个 Bitmap Watch = (Bitmap)Image.FromFile("Watch.jpg"); Actions a

在Selenium webdriver C#winform Firefox中,如何单击文档中的图像?这可能吗

让我解释一下

我的桌面上有一个名为watch.jpg的图像,我希望它在FireFox实例中找到该图像,并在该图像可见时单击该图像。那么按照这个顺序,

  • 查找图像

  • 移到图像

  • 单击图像

谢谢你的帮助

我试过这个

        Bitmap Watch = (Bitmap)Image.FromFile("Watch.jpg");
        Actions action = new Actions(driver);
        action.MoveToElement(Watch).Perform();
        action.Click().Perform();
有这些错误吗

错误1“OpenQA.Selenium.Interactions.Actions.MoveToElement(OpenQA.Selenium.IWebElement)”的最佳重载方法匹配具有一些无效参数

错误2参数1:无法从“System.Drawing.Bitmap”转换为“OpenQA.Selenium.IWebElement”163


我认为这是不可能的<代码>动作.MoveToElement(Watch.Perform()将仅使用webelement作为其参数。Intead
watch
属于
Bitmap
类型,因此出现错误
无法从“System.Drawing.Bitmap”转换为“OpenQA.Selenium.IWebElement”
。 您可以在C#中搜索基于图像的自动化工具(我不确定它是否存在)。如果是Java,你可以使用SIKULI。SIKULI是一种基于图像的工具自动化工具,它可以将图像作为输入,在屏幕上定位并对其执行操作


希望这对您有所帮助。

请向我们展示您迄今为止尝试使用的代码。它是如何工作的?