1

I am having a bit of trouble with this. I am trying to click on a check box with an ID that is different each page load.

This is the code I have that doesn't work:

Dim SegmentData As IWebElement = driver.FindElementByXPath("//*[starts-with(@id, 'gwt-uid-5')]")
SegmentData.click()

This is the xpath for the element:

//*[@id="gwt-uid-5324"]

The last 3 digits (324 in this case) are what change.

Nothing I try seems to work for me as each click attempt always fails.

Here is the exception thrown in this instance:

Exception thrown: 'OpenQA.Selenium.ElementNotVisibleException' in WebDriver.dll

And here is the HTML for the checkbox:

<div class="spee-f"> 
    <span class="gwt-CheckBox">
        <input type="checkbox" value="on" id="gwt-uid-5324" tabindex="0">    
        <label for="gwt-uid-5324">Segment statistics by month</label>     
    </span> 
</div>
3
  • Show exception log and HTML for check box Commented Aug 11, 2016 at 19:40
  • do as @Grasshopper stated, as well as show the containers (at least 2 up?) Commented Aug 11, 2016 at 19:41
  • Hi see my edit please @sircapsalot Commented Aug 11, 2016 at 19:47

1 Answer 1

1

Try following XPath and let me know it error still occurs:

//span[label[text()="Segment statistics by month"]]/input[@type="checkbox"]
Sign up to request clarification or add additional context in comments.

1 Comment

Worked like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.