0

I'm trying to use Selenium VBA to find checkbox elements on a web page. Interestingly, when I open a local HTML file, I can easily find and click the checkboxes without any issues. However, when I run the same code on a live website, Selenium cannot find the elements and nothing happens.

Here is the part of the code I am using:

Set kurulumCheckbox = WaitForElement(driver, "xpath", "//input[@type='checkbox' and @name='svcType' and @value='I']", 30) Set teslimatkurulumCheckbox = WaitForElement(driver, "xpath", "//input[@type='checkbox' and @name='svcType' and @value='X']", 30) If Not kurulumCheckbox Is Nothing Then kurulumCheckbox.Click End If If Not teslimatkurulumCheckbox Is Nothing Then teslimatkurulumCheckbox.Click End If 

This code works perfectly with my local HTML file, but on the live website, I'm unable to find or click the checkboxes. I can't figure out the difference between the two environments.

Browser: Chrome Driver: Selenium VBA (ChromeDriver) Wait Time: 30 seconds XPath and Elements: I'm confident the XPath is correct because it works on the local HTML file. 

Does anyone have suggestions for solving this issue? What extra checks should I perform when elements are not being found on live websites?

Thanks in advance for your help!

3
  • I would try opening the page in a browser and using the developer tools to interrogate the page; evaluating the XPath in the console, and checking the properties of the checkbox. It's hard to say, though, without seeing either the original website or the version of it which you've saved.CommentedSep 23, 2024 at 1:13
  • You could try retrieving all the input elements and dumping their attributes, to check they have the values you're expecting.CommentedSep 23, 2024 at 6:28
  • actually probably my first debugging step would be to retrieve the root html element as a WebElement and get its outerHTML property, and compare it with my pre-saved HTML file to ensure they are the same.CommentedSep 23, 2024 at 6:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.