org.openqa.selenium.WebDriverException:未知错误:无法读取null的属性'click'

时间:2018-05-31 04:50:14

标签: java selenium selenium-webdriver

将错误显示为

  

(org.openqa.selenium.WebDriverException:未知错误:无法读取   属性'click'为null)

有人可以帮助我解决以下问题吗? 通过Java Script Executor单击元素

单击Java Script Executor方法:

public static void ClickByJS(WebElement element, WebDriver driver){      
   JavascriptExecutor js = (JavascriptExecutor) driver;
   js.executeScript("arguments[0].click();", element);
}

以这种方式使用(driver.findElement By(Xpath))

WebElement titleDD = driver.findElement(By.xpath("//div[@aria- 
owns='registrationPageTitleSelect-dropdown-list']"));
ClickByJS(titleDD, driver);
public static void ClickByJS(WebElement element, WebDriver driver)
{
   JavascriptExecutor js = (JavascriptExecutor) driver;
   js.executeScript("arguments[0].click();", element);
 }

使用(FindBy())

时显示错误
@FindBy(xpath="//div[@aria-owns='registrationPageTitleSelect-dropdown- 
list']")
WebElement SelectTitleDropDown;

public void ValidateSelectTitle() 
{
   ClickByJS(SelectTitleDropDown, driver);
} 

0 个答案:

没有答案