skip to Main Content

I’m trying to click on input checkbox item on the Target.com website it looks like Selenium is trying to click on the whole label and I’m not able to click the input. The error output I get is:

OpenQA.Selenium.ElementClickInterceptedException : element click intercepted: Element

<input id="buyOnlineAndGetShipped" name="buyOnlineAndGetShipped" type="checkbox" class="styles__CheckboxInput-sc-1v63imw-1 hLCJBJ" value=""> 

is not clickable at point (348, 503). Other element would receive the click:

<div class="styles__CheckboxVisual-sc-1v63imw-5 gxIeGa"></div>

What I’m trying to do is go to https://www.target.com/s?searchTerm=dfgdfg

then click Help us improve this page

Then click the checkbox saying checking availability before a store trip

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement feedbackButton = wait.Until((d) => d.FindElement(By.ClassName("Feedback__Prompt-h2r4q4-1")));
feedbackButton.Click();
driver.FindElement(By.Id("buyOnlineAndGetShipped")).Click();
<div class="styles__StyledRow-sc-1nuqtm0-0 cuJjmE h-margin-v-tight h-text-md">
  <div class="styles__CheckboxOuterWrap-sc-1v63imw-0 geGlXr nds-checkbox" tabindex="-1">
    <input id="checkAvailabilityBeforeStoreTrip" name="checkAvailabilityBeforeStoreTrip" type="checkbox" class="styles__CheckboxInput-sc-1v63imw-1 hLCJBJ" value="">
    <label for="checkAvailabilityBeforeStoreTrip" class="styles__CheckboxWrap-sc-1v63imw-3 biROVs"><div class="styles__CheckboxVisual-sc-1v63imw-5 gxIeGa">
      </div><span class="Label__StyledLabelSpan-nz63ak-1 FgzNt styles__CheckboxLabel-sc-1v63imw-4 dOkNFG">checking availability before a store trip
      <span aria-atomic="true" aria-live="assertive" class="utils__ScreenReaderOnly-sc-1p6kq06-0 iyDnVM"></span></span></label>
</div></div>

2

Answers


  1. Actually your error is the proper error, that check box is not pointing to input tag, it is pointing to div tag only. so please change input to div

    //div[@class='styles__CheckboxVisual-sc-1v63imw-5 gxIeGa']
    

    enter image description here

    Login or Signup to reply.
  2. You should maximize the browser in full screen mode and then you can try with Java script executor like below :

    The below css has unique entry in HTMLDOM :

    IWebElement e = Driver.FindElement(By.CssSelector("label[for='checkAvailabilityBeforeStoreTrip'] div"));
    ((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].click();", e);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search