0

I have button in our website, and border areas of the button is not clickable. So, i need to make sure the button is getting clicked at the center. Is it possible via selenium?

I tried using coorinates, but it is not recommended for our scenario.

xpath used : //div/button[@id='clickme']

<div class="col-lg-10 col-sm-12 p-0 pt-4">
    <button class="click mb-3 " tabindex="0" id="clickme">+&nbsp;Click Here</button>
</div>

Java code used to click

WebElement button = driver.findElement(By.id("clickme"));
button.click();

I guess the click is happening sometimes[2 out of 10 times] on the border where it is not clickable(hand symbol not shown) . As a result report says the click action happened, but there is no event fired on the website.

Rinshad Hameed
  • 117
  • 1
  • 5
  • 16

1 Answers1

0

To identify the element with text as Click Here you can use either of the following Locator Strategies:

  • cssSelector:

    "button.click#clickme"
    
  • xpath:

    "//button[contains(@class, 'click') and @id='clickme'][contains(., 'Click Here')]"
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217