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
使用Selenium进行图像分级_Selenium - Fatal编程技术网

使用Selenium进行图像分级

使用Selenium进行图像分级,selenium,Selenium,我正在尝试使用selenium对一些图像进行评级 我将评级定为4(点击第四颗星),并使用firebug插件找到了评级字段的xpath。xpath是 css=img[alt="4"] 所以,我写了 selenium.click("css=img[alt="4"]"); 但这是一个错误 知道吗?给出哪个错误??如果找不到元素,请使用xpath作为 xpath=//img[@alt='4'] 你没有找到一个,而是一个 XPath解决方案: selenium.click("xpath=//img[

我正在尝试使用selenium对一些图像进行评级

我将评级定为
4
(点击第四颗星),并使用firebug插件找到了评级字段的
xpath
。xpath是

css=img[alt="4"]
所以,我写了

selenium.click("css=img[alt="4"]");
但这是一个错误


知道吗?

给出哪个错误??如果找不到元素,请使用xpath作为

xpath=//img[@alt='4']
你没有找到一个,而是一个

XPath解决方案:

selenium.click("xpath=//img[@alt='4']");
selenium.click("css=img[alt=4]");
CSS选择器解决方案:

selenium.click("xpath=//img[@alt='4']");
selenium.click("css=img[alt=4]");

出现错误,因为我在另一个分号中使用了分号。如果我使用selenium,请单击(“css=img[@alt='4']”);由于找不到元素,所以出现了错误。如果我使用selenium,请单击(“css=img[alt='4']”;没有错误发生。但什么都没有发生。我的意思是,它没有选择评级。如果什么都没有发生(没有错误,命令测试继续),这意味着它正常。你确定这是页面上唯一的评级图像吗?也许它点击了另一个?如果没有,单击可能不起作用-那么就有问题了。你可以用它来查看找到了什么元素。顺便说一句,链接的文档非常有用,它们也是很好的读物。是的。它是一个css选择器。我试过上面的代码。但它并不是在选择评级。也没有错误。