Currently, I am in the process of setting up an automated test using the basic page object pattern. The objective is to open Google, input a search query, click on a link from the results, and retrieve the information. So far, I have successfully navigated to the desired page. However, my challenge lies in extracting the contact information located at the bottom of www.sahipro.com and displaying it in the console of my test class. Despite my efforts, I find myself unable to filter out only the emails and numbers as I keep getting additional HTML content. Furthermore, I'm struggling to understand how to reference these page results within my test class.
The task of isolating the contact text and transferring it to a separate test class has proven daunting for me, considering my limited experience in this field.
try {
//Get Document object after parsing the html from given url.
Document document = Jsoup.connect("http://https://sahipro.com/").get();
Element support = document.text("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5e2d2b2e2e31...">
print(" Support Email: " + support);
}catch (IOException e) {
e.printStackTrace();
}
print("done");
}
public static void print(String string) {
System.out.println(string);
}
Although I have managed to fetch the information, it appears in HTML format when displayed in the console:
running...
Support Email: <html>
<head>
<meta http-equiv="refresh"
content="0;url=http://www.dnsrsearch.com/index.php
origURL=http://https%2Fsahipro.com%2F&bc=">
</head>
<body>
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ffcfaffffe0fd...">[email protected]</a>
</body>
</html>