selenium webdriver找到元素' href'不使用java工作

时间:2016-04-26 10:01:45

标签: selenium-webdriver

我正在使用selenium web驱动程序创建一个页面对象模型,并尝试链接一个具有' href'的元素。通过这种方式创造

first

我收到类似

的错误
  

无法从void转换为web元素。

任何人都可以帮助我吗

2 个答案:

答案 0 :(得分:0)

首先在浏览器中选择元素,然后复制它的选择器(inspect - >复制选择器)。然后将它用作cssSelector。尽量不要使用链接文本,因为它取决于语言。

答案 1 :(得分:0)

嗨,因为

,你会遇到上述错误
element = driver.findElement(By.partialLinkText("signin")).click();

you are trying to perform action (i.e click) and its object identification (element =...)
together whic h is not correct to make it work plz do it like below 
element = driver.findElement(By.partialLinkText("signin"));
element .click();

另外,为什么你会收到错误"无法隐藏从无效到网络元素" cause the type of .click() is void for more information please look at official documentation http://seleniumhq.github.io/selenium/docs/api/java/index.html 现在它将停止给你错误希望这可以帮助你

相关问题