0

I'm using Selenium in the following manner as below:

 ChromeOptions options = new ChromeOptions();
 /*options.addArguments("--headless");
 options.addArguments("--disable-gpu");
 options.addArguments("--disable-extensions");*/
 WebDriverManager.chromedriver().setup();
 ChromeDriver driver = new ChromeDriver(options);
 driver.get("https://gearbest.net/");
 WebElement ulElement = driver
 .findElement(By
 .cssSelector("body > div:nth-child(18) > div > div > div > div.tablets_content.clean > div > ul"));
 List<WebElement> liElements = ulElement.findElements(By.tagName("li"));
 //List<Article> articleList = new ArrayList<>();
 //try {
 /*org.jsoup.nodes.Document doc = Jsoup.connect("https://gearbest.net/products/").userAgent("Opera").get();
 Elements liElements = doc
 .select("#main > div.default_products_list.default_products_list1 > div.themes_plist_right > div");*/
 // class of the whole element
 liElements.forEach(liElement -> {
 String str = ""; // this line for debugging purposes, it's redundant if we speak about production code
...

I have the problem while debugging with getting li elements because of incorrect data.

I suppose it happens because of some missing things.

enter image description here

I'm ready to provide more information per your requirements, if you need.

Previously, I did it using Jsoup as a tool:

 org.jsoup.nodes.Document doc = Jsoup.connect("https://gearbest.net/products/").userAgent("Opera").get();
 Elements liElements = doc
 .select("#main > div.default_products_list.default_products_list1 > div.themes_plist_right > div");

But, as for now, it doesn't work because of updated version of the website, unfortunately.

I have already checked another similar question, but it doesn't look as my current use case.

If I find the way how to realize it, I'll answer on my own question.

I'm attaching additionally for you, as well, HTML for the current question.

Thank you for your attention :)

asked Aug 4, 2023 at 10:27
2
  • 1
    Could you please add the relevant HTML? It's possible there's a better and more accurate selector than the one you are using and that might be the problem. Commented Aug 4, 2023 at 12:22
  • @KatePaulk, yes, sure, I'll update now my question :) Commented Aug 4, 2023 at 20:28

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.