I only want to get and verify all links accessible in the footer (object= footer_wrapper clearfix) of this page: https://www.universiteitleiden.nl/en/education.
I found the keyword to getAllLinksOnCurrentPage, but that’s to much. Please advice.
I only want to get and verify all links accessible in the footer (object= footer_wrapper clearfix) of this page: https://www.universiteitleiden.nl/en/education.
I found the keyword to getAllLinksOnCurrentPage, but that’s to much. Please advice.
Create a new test object contains selector to these link, such as //div[@id=footer].
In your test case, uses the following code to get all links from above object.
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import org.openqa.selenium.WebElement
import com.kms.katalon.core.webui.common.WebUiCommonHelper
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebElement element = WebUiCommonHelper.findWebElement(findTestObject("/path/to/your/object"), 30)
List URLs = element.getAttribute(‘href’)
This will return all links within that object
It’s not working yet. The code isn’t giving any errors, but it doesn’t get the URL’s either. This is my code:
WebElement element = WebUiCommonHelper.findWebElement(findTestObject('Object Repository/STW_footer/ul'),
30)
List URLs = element.getAttribute('href')
WebUI.verifyLinksAccessible(URLs)
I tried existing objects and making a new object, but with no result. I also don’t have something like an id=footer somewhere in the code. I only have classes like class=footer-container and / or class=wrapper clearfix, but none of these work.
I want to get all URL’s within the footer on this page (https://www.universiteitleiden.nl/en/education.) and verify if the links are accessible. Please help with the last pieces of this puzzle. Thanks.
Hello, how can i get the response status code of a URL, not a object?
I’m using this keyword:
links = WebUI.getAllLinksOnCurrentPage(true, [])
for (url in links) {
println(url)
}
I want to get the status code of each URL string (ex: 200, 404)
Thanks
K. Alsemgeest said:
It’s not working yet. The code isn’t giving any errors, but it doesn’t get the URL’s either. This is my code:
WebElement element = WebUiCommonHelper.findWebElement(findTestObject('Object Repository/STW_footer/ul'), 30)List URLs = element.getAttribute('href')WebUI.verifyLinksAccessible(URLs)
I tried existing objects and making a new object, but with no result. I also don’t have something like an id=footer somewhere in the code. I only have classes like class=footer-container and / or class=wrapper clearfix, but none of these work.
I want to get all URL’s within the footer on this page (https://www.universiteitleiden.nl/en/education.) and verify if the links are accessible. Please help with the last pieces of this puzzle. Thanks.
Hi!
Have you been able to get it?
Im trying to create the same script that u want but i don’t get it…
Hi,
Is there a way to find the broken links using Katalon ?
If so, can i able to upload the links from excel to katalon and validate?
Hello,
I would like to ask you about get and verify links within footer
I tried link from documentation but it doesnt give me result, please any help , do you have any example how can automated ? Thank you
===
Here is the code i wrote for Getting all the links in Footer :
@Keyword
public ArrayList verifyFooterSection(String divID) {
KeywordUtil.logInfo(“Get all Footer links”)
String ModifiedString="";
ModifiedString=divID.toLowerCase();
ListActualFooterLinks=new ArrayList();
WebElement element = driver.findElement(By.id(ModifiedString));
List options = element.findElements(By.tagName(“a”));
//System.out.println(options.size());
int ActualLinksSize = 0;
for (WebElement we : options) {
String strLinkName = we.getText()
//println strLinkName.isEmpty()
if (strLinkName == null || strLinkName.isEmpty()){
}else{
ActualFooterLinks.add(strLinkName)
ActualLinksSize=ActualLinksSize+1
println ActualLinksSize + " : Footer Link Name : " + strLinkName
}
}
//}
println ActualLinksSize
}
any of you guys can explain or give the solution to me?
I am getting errors using the methods explained here so far. Thanks
Hi @Bal_Mukund
It seems that findWebElements
return an ArrayList
and you are trying to pass it into an Object element. Please append .get(0)
into the end of that line:
element = findWebElements(findTestObject('pathToObject'), 20).get(0)
Please note that this does not necessarily mean that your test will pass, because there’s a chance the XPath you are using may be wrong or the element you are trying to locate doesn’t appear after 20 seconds. In that case you will get an empty list and you should re-check your XPath or set a longer time out.
Have a nice day !
@ThanhTo my object xpath is correct, will make sure it stays so.
please help me out with following:
WebElement element = WebUiCommonHelper.findWebElements(findTestObject(‘Object Repository/TextMatchingObjects/PreviewHref’), 20).get(0)
List URLs = element.getAttribute(‘href’)
WebUI.verifyLinksAccessible(URLs)
Or if you can guide me to create a custom keyword to get links from an object and verify if they are accessible. the getAllLinksOnCurrentPage gets all links from the page which increases test time. Or any feasible solution for this challenge
HI @Bal_Mukund
You can wrap an object with Arrays.asList
to convert it into a list, like this:
List URLs = Arrays.asList(element.getAttribute(‘href’))
I am using this script :
List allURLs = WebUI.getAllLinksOnCurrentPage(true, )
println ('Total links on page: ’ +allURLs.size())
WebElement element = WebUiCommonHelper.findWebElement(findTestObject('Object Repository/Progression/Management/StudentPLinkVerification/MainMenuLinks'))
List URLs = element.getAttribute('href')
print URLs
Getting no error but result is coming null
HTML:
Adding locator-
.//*[@class=“headerlinksdiv”]/span/map/p/table/tbody/tr/td/table/tbody/tr
If i search in chrome , it highlights this navigation menu bar
Please also provide the details of the Test Object (i.e Selected Locator). Can you throw that locator into Chrome’s DevTool to see if it correctly locates the a element.
added both , please refer
Hi @shilpi1
the locator
.//*[@class=“headerlinksdiv”]/span/map/p/table/tbody/tr/td/table/tbody/tr
doesn’t seem to locate the link, seeing that it ends with tr
and not a
. Please use Spy Tool to capture the link element and then use that as a Test Object instaed of this one.
Note sure how else I can make generalised xpath, .//*[@class=“headerlinksdiv”]/span/map/p/table/tbody/tr/td/table/tbody/tr/td
I used it because inside last td tag is coming… please suggest suggest
In the Dev Tools (the picture you posted), right click on the a
element which contains the href
attribute and choose Copy > Copy XPath and use that instead.