如何选中复选框并获取是否在javascript selenium中选中复选框

时间:2021-01-21 00:10:58

how to check check box and getting whether checkbox is checked in javascript selenium and node. I tried using .click on the element also tried using native javascript code to do that.but nothing worked for me.

如何选中复选框并获取是否在javascript selenium和节点中选中复选框。我尝试在元素上使用.click也尝试使用原生的javascript代码来做到这一点。但是没有什么对我有用。

driver.findElement(webdriver.By.id('//*    
[@id="myTable"]/table/tbody/tr[1]/td[1]/input')).
then(function(element){
   element.click().then(function(){//body goes here

};

I have edited the code in SO itself so there might be braces problem.in actual code its not the braces problem.

我已经在SO中编辑了代码,因此可能存在大括号问题。在实际代码中它不是括号问题。

any solutions to do so?

任何解决方案吗?

1 个解决方案

#1


3  

You need to change webdriver.By.id to webdriver.By.xpath as you are using xpath here

您需要将webdriver.By.id更改为webdriver.By.xpath,因为您在此处使用xpath

#1


3  

You need to change webdriver.By.id to webdriver.By.xpath as you are using xpath here

您需要将webdriver.By.id更改为webdriver.By.xpath,因为您在此处使用xpath