티스토리 뷰
Jenkins : 2.218
Selenium : 3.141.59
Java : 1.81.8.0_221
Jenkins, Java, Gradle, Junit 등은 기본 사용 가능하다고 가정한다.
1. Jenkins에서 Selenium Grid 플러그인을 설치한다.
2. 셀레니움 jar 다운로드
3. Jenkins에서 Selenium Grid 설정
JSON 형태로 셋팅하였으며, [https://www.softwaretestinghelp.com/selenium-grid-selenium-tutorial-29/] 사이트를 참고하였다.
4. Selenium Hub 시작
정상적이라면 아래와 같은 화면이 보인다. 쉽지않았다. 여러가지 이유로 이 화면을 보는데까지 오래 걸렸다.
5. Selenium Node 실행
* java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://pms.uicom.kr:4444/grid/register
Node 실행후 Hub 의 변한 모습
6. Selenium Hub를 이용한 테스트 실행
public class Xsp001 {
@Test
public void Login() throws MalformedURLException {
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setBrowserName(BrowserType.FIREFOX);
capability.setPlatform(Platform.WINDOWS);
WebDriver driver = new RemoteWebDriver(new URL("http://pms.uicom.kr:4444/wd/hub"), capability);
driver.get("http://localhost/auth/login");
WebElement userId = driver.findElement(By.id("user_id"));
WebElement userPassword = driver.findElement(By.id("user_pw"));
// userId.sendKeys("tester");
userId.sendKeys("admin");
userPassword.sendKeys("password");
driver.findElement(By.id("loginBtn")).click();
System.out.println("Page title is: " + driver.getTitle());
Assert.assertEquals("XPOSSP", driver.getTitle());
System.out.println("Login Test");
System.out.println(driver.getTitle());
}
}
※ 참고자료
- Selenium 셋팅 방법 [https://github.com/SeleniumHQ/selenium/wiki/Grid2#configuring-the-nodes-by-json%20for%20more%20details]
- karma 를 이용한 셋팅방법 [https://meetup.toast.com/posts/132]
- Selenium Grid Tutorial: Hub & Node (with Example) [https://www.guru99.com/introduction-to-selenium-grid.html]
댓글