URLs extraction and verification from local HTML file

Hello!
I’m new to this. I have an issue with getting URLs from HTML file.
Basically task is:

  1. Open local html file
  2. Get list of URLs that are contained in that HTML file
  3. Check if those URLs contain specific parameters/values

I’ve tried this piece of code, that I found in forum:

WebUI.openBrowser(‘file:///C:/Users/JohnDoe/Documents/myTest.html’)

WebElement element = WebUiCommonHelper.findWebElement(findTestObject(‘Additional Elements/html body’), 30)

List URLs = element.getAttribute(‘href’)

This suppose to list all URLs, if I understood correctly, but it does not. Code successfully ends, with no errors, but URLs isn’t listed.
I would appreciate any help on my task :slight_smile:

1 Like

I can see one small issue in your code.

// returns: WebElement
WebUiCommonHelper.findWebElement()

// returns: List<WebElement>
WebUiCommonHelper.findWebElements()

You use first one, but you should use second one. Try this quick fix and see if it helps.