I have an issue, my test case is as follows:
whois.net
But my test is not able to make a click. I don't understand why?
Here is my code (Maybe you can advise something for me):
WebElement registerButton = driver.findElement(By.cssSelector("div#hdSearch span input a"));
registerButton.click();
I got the next error:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"div#hdSearch span input a"}
答案 0 :(得分:0)
首先看一下whois.net有助于知道需要更清晰的选择器链接,XPATH就像这样:
/html/body/form/div[5]/div[2]/div[1]/div[1]/table/tbody/tr/td/a
所以请尝试:
WebElement registerButton = driver.
findElement(
By.xpath("/html/body/form/div[5]/div[2]/div[1]/div[1]/table/tbody/tr/td/a")
);
registerButton.click();
答案 1 :(得分:0)
要找到搜索按钮并单击它,您可以使用以下代码块:
WebElement registerButton = driver.findElement(By.cssSelector("div#searchBox a"));
registerButton.click();