如何在Java中使用Selenium单击此链接
我在这个网站上,我正在尝试使用selenium webDriver点击批量搜索: 链接的HTML代码为:如何在Java中使用Selenium单击此链接,java,html,selenium,href,Java,Html,Selenium,Href,我在这个网站上,我正在尝试使用selenium webDriver点击批量搜索: 链接的HTML代码为: <a href="landing_page.php?pgcontent=batch_search" style="color:white; font-weight:bold; font-size:13px">Batch Search </a > 然而,这似乎不起作用。 有什么想法吗?我喜欢使用css选择器,它是: String selector = "a[href
<a href="landing_page.php?pgcontent=batch_search" style="color:white; font-weight:bold; font-size:13px">Batch Search </a >
然而,这似乎不起作用。
有什么想法吗?我喜欢使用css选择器,它是:
String selector = "a[href=\"landing_page.php?pgcontent=batch_search\"]";
driver3.findElement(By.cssSelector(selector)).click()
linkText是完全匹配的,但批处理搜索后有一个额外的空格字符,该字符在查询中不存在,因此不匹配
修复搜索查询或使用partialLinkText
String selector = "a[href=\"landing_page.php?pgcontent=batch_search\"]";
driver3.findElement(By.cssSelector(selector)).click()