-
-
Save Jiveloper/f052635c6813c0741185b8ccecf4065d to your computer and use it in GitHub Desktop.
StreamAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import java.util.*; | |
public class Refactoring { | |
public static void main(String[] args) { | |
WebDriver driver = new ChromeDriver(); | |
driver.get("https://www.wanted.co.kr/"); | |
List<WebElement> elements = driver.findElements(By.xpath("//ul[@class='Menu_className__gGcYQ']//li")); | |
beforeImprovement(elements); | |
driver.quit(); | |
} | |
private static void beforeImprovement(List<WebElement> elements) | |
{ | |
Set<String> set = new HashSet<>(); | |
for (WebElement element: elements) | |
{ | |
String category = element.getText(); | |
if (category.length() > 0) | |
{ | |
set.add(category); | |
System.out.println(category); | |
System.out.println(category.getClass().getName()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment