본문 바로가기
기타

Selenium Grid 셋팅하기

by 앗사비 2015. 8. 10.
728x90

지난 포스팅에 이어서 원격으로 크롬 돌리는 예제

selenium-server-standalone-XXX.jar 파일은 허브/노드에 각각 준비되어 있어야 한다


1. 서버 PC (허브)

java -jar selenium-server-standalone-[version].jar -role hub -port 4444 -nodeTimeout 600


2. 클라이언트 PC (노드) - 테스트 브라우저 실행

java -jar selenium-server-standalone-[version].jar -role webdriver -hub http:[hub ip]:4444/grid/register -Dwebdriver.chrome.driver=C:\..[path]..\chromedriver.exe -port 5555


3. 이클립스 실행하는 PC

import org.junit.*;
import static org.junit.Assert.*;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.junit.runners.MethodSorters;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SeleniumGridTest {
	private static WebDriver driver;
	private static StringBuffer verificationErrors = new StringBuffer();

	@BeforeClass
	public static void setUp() throws Exception {
		DesiredCapabilities cap = new DesiredCapabilities();
		cap = DesiredCapabilities.chrome(); 
		cap.setBrowserName("chrome"); 
		cap.setPlatform(Platform.WINDOWS);
        driver = new RemoteWebDriver(new URL("http://[hub ip]:4444/wd/hub"), cap);
	}

	@Test
	public void T01() throws Exception {
		driver.get("http://naver.com");
	}

	@Test
	public void T02() throws Exception {
		driver.get("http://google.com");
	}

	@AfterClass
	public static void tearDown() throws Exception {
		driver.close();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}
}

728x90

'기타' 카테고리의 다른 글

syntax highlighter - autoit brush  (0) 2015.08.25
[autoit] 치트 시트  (0) 2015.08.13
Eclipse + Selenium Webdriver + JUnit 활용하기  (0) 2015.08.07
[autoit] 부팅 후 네이트온 창 닫기  (0) 2015.08.03
파일명 길이 제한  (0) 2015.07.29