문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
wiki:java:selenium [2020/11/11 21:59] hylee |
wiki:java:selenium [2023/01/13 18:44] (현재) |
||
---|---|---|---|
줄 42: | 줄 42: | ||
{{: | {{: | ||
\\ | \\ | ||
- | ===== Selenium이란? | + | ===== maven ===== |
<code java> | <code java> | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Selenium code ===== | ||
+ | ==== java ==== | ||
+ | <code java> | ||
+ | |||
+ | |||
+ | |||
package main; | package main; | ||
줄 72: | 줄 86: | ||
// Chrome 드라이버 인스턴스 설정 | // Chrome 드라이버 인스턴스 설정 | ||
driver = new ChromeDriver(); | driver = new ChromeDriver(); | ||
- | // 스크립트를 사용하기 위한 캐스팅 | ||
- | // | ||
- | |||
- | // element 에 버튼을 찾아서 넣어주고 아래와 같이 작성하면 | ||
- | // 해당 버튼을 클릭합니다. | ||
- | // | ||
// 접속하고 싶은 URL | // 접속하고 싶은 URL | ||
줄 86: | 줄 94: | ||
driver.manage().timeouts().implicitlyWait(2, | driver.manage().timeouts().implicitlyWait(2, | ||
// xpath 패턴의 값 selector. | // xpath 패턴의 값 selector. | ||
- | WebElement element | + | WebElement element; |
// test를 위한 배열 | // test를 위한 배열 | ||
- | String[] s_array = new String[2]; | + | String[] s_array = new String[3]; |
s_array[0] = "This book aims to strengthen an understanding of the sculptural possibilities of form and space through developing a visual language and structure that recognizes and "; | s_array[0] = "This book aims to strengthen an understanding of the sculptural possibilities of form and space through developing a visual language and structure that recognizes and "; | ||
s_array[1] = "gives priority to 3dimensional visual perception It is written so as to apply to both the active process of shaping 3D form and space and analyzing any existing visual situation Introduction"; | s_array[1] = "gives priority to 3dimensional visual perception It is written so as to apply to both the active process of shaping 3D form and space and analyzing any existing visual situation Introduction"; | ||
+ | s_array[2] = " | ||
- | // 배열 반복문 | + | // *[@id=" |
- | for (String | + | // 배열 반복문 |
+ | for (String | ||
{ | { | ||
+ | // 언어선택하는 버튼 | ||
+ | element = driver.findElement(By.xpath("// | ||
+ | // 언어선택하는 버튼 클릭 | ||
+ | element.click(); | ||
- | element.sendKeys(aa); | + | Thread.sleep(1000); |
+ | // 언어감지 버튼 선택 | ||
+ | element = driver.findElement(By.xpath( | ||
+ | "// | ||
+ | // 언어감지 버튼 클릭 | ||
+ | element.click(); | ||
+ | // 번역 할 input창 선택 | ||
+ | element = driver.findElement(By.xpath("// | ||
+ | // 번역 할 input창에 문장 넣기 | ||
+ | element.sendKeys(str); | ||
// 대기 설정 | // 대기 설정 | ||
Thread.sleep(1000); | Thread.sleep(1000); | ||
- | |||
// css 패턴의 값 selector. | // css 패턴의 값 selector. | ||
WebElement elementd = driver.findElement(By.cssSelector("# | WebElement elementd = driver.findElement(By.cssSelector("# | ||
System.out.println(" | System.out.println(" | ||
- | |||
// element 초기화 | // element 초기화 | ||
element.clear(); | element.clear(); | ||
줄 130: | 줄 151: | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ==== consol ==== | ||
+ | elementd : 이 책은 인식하고 인식하는 시각적 언어와 구조를 개발하여 형태와 공간의 조각 적 가능성에 대한 이해를 강화하는 것을 목표로합니다. | ||
+ | elementd : 3 차원 시각 인식을 우선시하며 3 차원 형태와 공간을 형성하는 능동적 인 과정과 기존의 시각 상황을 분석하는 과정 모두에 적용 할 수 있도록 작성되었습니다. | ||
+ | elementd : 단어, 구, 구에 사용할 수있는 유료 서비스 | ||
+ | \\ | ||
+ | \\ | ||
+ | | ||
+ | | ||
+ | ===== CentOS에 크롬설치 ===== | ||
+ | '' | ||
+ | 크롬드라이버도 리눅스 버전을 받아야 합니다. \\ | ||
+ | \\ | ||
+ | 1. 크롬 repo 등록 \\ | ||
+ | <code bash> | ||
+ | $ vi / | ||
+ | </ | ||
+ | |||
+ | [google-chrome] | ||
+ | name=google-chrome | ||
+ | baseurl=http:// | ||
+ | enabled=1 | ||
+ | gpgcheck=1 | ||
+ | gpgkey=https:// | ||
+ | |||
+ | |||
+ | 2. 크롬 설치 \\ | ||
+ | <code bash> | ||
+ | $ yum install google-chrome-stable | ||
+ | </ | ||
+ | \\ | ||
+ | 3. 크롬 버전 확인 \\ | ||
+ | <code bash> | ||
+ | $ google-chrome --version | ||
</ | </ | ||
+ | \\ | ||
+ | | ||
+ | ===== Tip ===== | ||
+ | 자바코드를 실행하면 크롬창이 뜨면서 번역하는 과정이 보여집니다. | ||
===== Troubleshooting ===== | ===== Troubleshooting ===== |