Selenium Webdriver Find element by 'href' 不使用 Java 工作



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

[element = driver.findElement(By.partialLinkText("signin")).click();]

我收到类似

无法从虚空隐蔽到网页元素。

任何人都可以帮我解决这个问题吗

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

嗨,

你得到上面的错误,因为

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();

另外,为什么您会收到错误"无法从虚空隐蔽到Web元素"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现在它将停止给你错误希望这对你有帮助

最新更新