본문 바로가기

반응형

전체 글

(186)
filter() 함수 filter는 해석 그대로 걸러주는 역할을 하는 함수이다. 주로 특정 조건을 만족하는 새로운 배열을 필요로 할 때 사용하는 편이다. SQL로 치면 where절에서 하는 행위를 하는 함수이다. 예제 const numbers = [1, 2, 3, 4, 5]; const result = numbers.filter(number => number > 3); console.log(numbers); // [1, 2, 3, 4, 5]; console.log(result); // [4, 5] 중복 제거하기 const numbers = [1, 1, 2, 2, 3, 4, 5]; const newNumbers = numbers.filter((number, index, target) => { return target.index..
repeat() 함수 repeat() 메서드는 문자열을 주어진 횟수만큼 반복해 붙인 새로운 문자열을 반환해주는 메서드이다. str = "123"; strRepeat = str.repeat(3); console.log(strRepeat); // 123123123 // `` 을 사용한다면 ${} 안에 넣어주면 된다. str = ['1', '2', '3', '4', '5']; for(let i = 0; i < str.length; i ++){ console.log(`${str[i].repeat(i+1)}\n`); } // 1 // 22 // 333 // 4444 // 55555 [출처] https://ant-programmer.tistory.com/16
LinkedList 예제 class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.size = 0 def append(self, data): if self.head is None: self.head = Node(data) else: node = self.head while node.next: node = node.next node.next = Node(data) self.size += 1 def print_list(self): p = self.head if p is not None: while p: if p.next is not None: print(p..
Selenium - JavaScriptExecutor JavaScriptexecutor가 필요한 이유 Selenium Webdriver에서 XPath, CSS 등과 같은 로케이터는 웹 페이지에서 작업을 식별하고 수행하는 데 사용됩니다. 이러한 로케이터가 작동하지 않는 경우 JavaScriptExecutor를 사용할 수 있습니다. JavaScriptExecutor를 사용하여 웹 요소에서 원하는 작업을 수행할 수 있습니다. Selenium은 javaScriptExecutor를 지원합니다. 추가 플러그인이나 추가 기능이 필요하지 않습니다. JavaScriptExecutor를 사용하려면 스크립트에서 가져오기( org.openqa.selenium.JavascriptExecutor ) 만 하면 됩니다.. 사용하는 방법 1. Import the package. impo..
Selenium - xpath를 이용해, 동일한 상위 요소 아래에서 다른 하위 요소를 선택하는 방법(C#) element = Driver.FindElement(By.XPath("//input[@class='x-input select2-offscreen' and contains(@name,'" + fieldName + "')]//preceding::div[1]/a/span[@class='select2-chosen']")); [출처] https://stackoverflow.com/questions/49702167/selenium-how-to-choose-another-child-element-under-the-same-parent-element-c
Selenium - xpath selenium으로 특정 element를 가져올 때, 가져오고 싶은 element가 다른 element 안에 있을 경우에 그 특정 element를 쉽게 가져올 수 있는 방법 중 하나인 xpath를 사용해 element를 가져오는 방법에 대해서 작성하였다. xpath(XML Path Language)란? W3C의 표준으로 XML(Extensible Markup Language)문서의 구조를 통해 경로(Path)위에 지정한 구문을 사용하여 항목을 배치하고 처리하는 방법을 기술하는 언어입니다. XML 표현보다 더 쉽고 약어로 되어 있으며, XSL변환(XSLT)과 XML지시자 언어(XPointer)에 쓰이는 언어로 XML 문서의 Node를 정의하기 위하여 경로식(Path Expression)을 사용하며, 수학 ..
Selenium - 아래 또는 위로 스크롤하는 방법 1. pixel을 이용해서 스크롤 아래로 내리기 import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class ScrollByPixel { WebDriver driver; @Test public void ByPixel() { System.setProperty("webdriver.chrome.driver", "E://Selenium//Selenium_Jars//chromedriver.exe"); driver = new ChromeDriver(); ..
Selenium - Waits Selenium을 사용해 테스트를 할 때 element를 찾을 수 있도록 Web Page가 로딩이 끝날때까지 기다려야 한다. AJAX를 이용해 만든 Web의 경우 리소스가 로드하는데 부문별로 다를 수 있다. Selenium에서는 두 가지 타입의 wait 메서드를 제공한다. 1. Explict Waits 특정 상태가 될 때까지 기다리고, 상태가 되면 바로 실행한다. from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as ..

반응형