I’m making an attempt to get the identify and the worth info from this web site with XPath. When i write my XPath expression down within the search bar it locates appropriately within the chrome. However in VSC it would not work. I get nameHtml is null error. That is the one component that has style__Text-sc-__sc-1nwjacj-0 iwTTHJ sc-dd9e2587-8 dsYcan
class. Is there an issue with my expression or the code ?
Thanks
my code:
public class Principal {
public static HtmlPage getDocument(String url) {
HtmlPage web page = null;
attempt (closing WebClient webClient = new WebClient()) {
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);
web page = webClient.getPage(url);
} catch (IOException e) {
e.printStackTrace();
}
return web page;
}
public static void major(String[] args) throws IOException {
WebClient webClient = new WebClient();
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false);
HtmlPage web page = getDocument("https://getir.com/en/class/fruits-veg-tBYm30SlS9/");
HtmlElement nameHtml = web page.getFirstByXPath("//div[@class="style__Text-sc-__sc-1nwjacj-0 iwTTHJ sc-dd9e2587-8 dsYcan"]");
System.out.println(nameHtml.asNormalizedText());}