Skip to main content
edited body
Source Link
dzieciou
  • 10.5k
  • 9
  • 48
  • 102

I have this HTML

<div class="btnContr">
     
  <input type="button" onclick="return cancel();" value="Cancel"/>

Below is the xpath identified, using this xpath, I am not able to click on the button.

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written:

JavascriptExecutor jse = (JavascriptExecutor)ff;
            jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

What should my code be?

I have this HTML

<div class="btnContr">
 
<input type="button" onclick="return cancel();" value="Cancel"/>

Below is the xpath identified, using this xpath, I am not able to click on the button.

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written:

JavascriptExecutor jse = (JavascriptExecutor)ff;
            jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

What should my code be?

I have this HTML

<div class="btnContr">    
  <input type="button" onclick="return cancel();" value="Cancel"/>

Below is the xpath identified, using this xpath, I am not able to click on the button.

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written:

JavascriptExecutor jse = (JavascriptExecutor)ff;
            jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

What should my code be?

Added code callouts to HTML, XPath and written code
Source Link
Kate Paulk
  • 31.5k
  • 8
  • 55
  • 109
 

I have this HTML

<div class="btnContr">

<input type="button" onclick="return cancel();" value="Cancel"/>

Below is the xpath identified, using this xpath  , iI am not able to click on the button. Can you please suggest

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written: JavascriptExecutor jse = (JavascriptExecutor)ff; jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

JavascriptExecutor jse = (JavascriptExecutor)ff;
            jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

What should my code be?

 

Below is the xpath identified, using this xpath  , i am not able to click on the button. Can you please suggest

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written: JavascriptExecutor jse = (JavascriptExecutor)ff; jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

I have this HTML

<div class="btnContr">

<input type="button" onclick="return cancel();" value="Cancel"/>

Below is the xpath identified, using this xpath, I am not able to click on the button.

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written:

JavascriptExecutor jse = (JavascriptExecutor)ff;
            jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");

What should my code be?

Source Link
user6633
  • 1
  • 1
  • 1
  • 1

JavascriptExecutor is not identifying the button to click in Webdriver

Below is the xpath identified, using this xpath , i am not able to click on the button. Can you please suggest

Xpath=//div[@class='btnContr']/input[@onclick='return cancel();']

Code written: JavascriptExecutor jse = (JavascriptExecutor)ff; jse.executeScript("document.getElement(By.xpath('//div[@class='btnContr']/input[@onclick='return cancel();']').click()");