-2

I have tried everything. I am unable to track also.

<button accesskey="c" id="Continue" class="jfabtn" type="button" onclick="submitForm()"><u>C</u>ontinue</button>

My code

driver.findElement(By.id("Continue")).click();

or

driver.findElement(By.xpath("//*[@id=Continue]");

­

<button accesskey="x" id="Exit" class="jfabtn" type="button" onclick="exit()">E<u>x</u>it</button>

My code

driver.findElement(By.id("Exit")).click();

or

driver.findElement(By.xpath("//*[@id=Exit]");
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Can you be more explicit about *I cannot click*? Did you get any exception? – Andersson Aug 24 '17 at 07:26
  • As you are not mentioning any error here, so i am assuming that by executing above code, you won't get any error, so try to click on button element using `javascript-Executor` Method. For more details on this issue, refer my answer below. – Jainish Kapadia Aug 24 '17 at 07:35
  • You need to check for a frame. If there is any frame present then you need to switch to frame first.. – Shubham Jain Aug 24 '17 at 08:51
  • refer :- https://www.guru99.com/handling-iframes-selenium.html – Shubham Jain Aug 24 '17 at 08:51
  • refer :- https://stackoverflow.com/questions/10879206/how-to-switch-between-frames-in-selenium-webdriver-using-java – Shubham Jain Aug 24 '17 at 08:51
  • What error are you getting? My guess is that it's either in an iframe that you need to switch to or it's a case where you need a wait. Try both of those and report back if anything worked or post the additional error messages. – JeffC Aug 24 '17 at 14:04

2 Answers2

0

Try to click on button using javascript-Executor Method.

WebElement button = driver.findElement(By.id("Continue"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", Continue);
Jainish Kapadia
  • 2,603
  • 5
  • 18
  • 29
-2

Please try this code:

driver.findElement(By.xpath("//**Enter here class name of that element**[contains(@id,'Exit')]")).click();
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
  • 1
    Why OP should *enter class name of that element* instead of node name? Why specifying partial `id` value is better than specifying exact `id`? – Andersson Aug 24 '17 at 07:29