-
-
Save Jiveloper/f10da97441668674e46a54de5b917eac to your computer and use it in GitHub Desktop.
스트림
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")); | |
afterImprovement(elements); | |
driver.quit(); | |
} | |
private static void afterImprovement(List<WebElement> elements) | |
{ | |
elements.stream() | |
.map(WebElement::getText) | |
.distinct() | |
.filter(s -> s.length() > 0) | |
.forEach(System.out::println); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment