0

操作:WebElement.Click()在Chrome和IE浏览器的驱动程序不能正常工作

我想用下面的XPath

WebElement checkBoxSelection = driver.findElement(By.xpath("//*[@id='tblusref']/tbody/tr[1]/td[2]/input")); 
checkBoxSelection.click(); 

我的XPath是正确的,也与Chrome开发者工具验证选中该复选框,但在执行过程中它不是单击复选框,我没有得到任何的异常

同其在Firefox的驱动程序完美的工作,它不是在Chrome和IE, 工作请帮助我怎样才能解决这个问题

驱动程序相关

<groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-chrome-driver</artifactId> 
      <version>2.53.1</version> 

<groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-ie-driver</artifactId> 
      <version>2.42.2</version> 
+0

[NG模式 - 选中该复选框的Xpath无法在Chrome和IE司机工作]的可能的复制(http://stackoverflow.com/questions/41115126/ng-model- check-the-checkbox-xpath-not-working-in-chrome-and-ie-driver) – Guy

+0

请不要问同样的问题两次。 – Guy

+0

@Guy:不重复,我编辑了我以前的问题,并没有得到反馈,这样我就当前问题提出了新的问题 – Prabu

回答

0
try to update to version 3.X 
update the chrome driver also 
i am adding a method that can help u debug 
it highlight the place you click 
(please use shorter path and if u can change it to css selector) 

public void highligh(By cssSelector) { 
     JavascriptExecutor js = (JavascriptExecutor) getDriver(); 
     js.executeScript("arguments[0].style.border='2px groove green'", driver.findElement(cssSelector)); 
    } 
相关问题