I am currently training in Selenium. The objective of the task is to:
- Navigate to a random Wikipedia page
- Pick a random category from the page's list of categories
- Select a random article from the list of pages in the selected category
- Output the compared differences between the categories of the original random page and the second one.
I have gotten all the way to the category page, but for some reason the code wont click on a random article within that page.
Here is my current code for the category page
//Navigating to the category list at the bottom of the page
WebElement Category = driver.findElement(By.id("mw-normal-catlinks"));
Category.click();
//finds a random link in the category list
Random r = new java.util.Random();
List<WebElement> links = driver.findElements(By.tagName("mw-pages"));
//picks a random link
WebElement randomElement = links.get(r.nextInt(links.size()));
WebElement NewCategory = driver.findElement(By.id("mw-pages"));
NewCategory.click();
Random n = new java.util.Random();
List<WebElement> ArticleLinks = driver.findElements(By.tagName("mw-pages"));
WebElement randomElement2 = ArticleLinks.get(n.nextInt(ArticleLinks.size()));
Aucun commentaire:
Enregistrer un commentaire