대단원! 초심자 인 Selenium WebDriver를 만나서 반갑습니다! 시작하는 데 도움이되는 프로젝트를 권하고 싶습니다.
그것은하지 메이븐을 사용하는 데 필요한
here
당신은 그것을 here을 다운로드하거나 GitHub의에서 체크 아웃 할 수 있지만, 매우 메이븐, 개미와 같은 의존성 관리 소프트웨어의 일종을 사용하는 것이 좋습니다입니다 , 또는 다른 사람. 왜? 왜냐하면 jar 파일이 있고 여러 참여자가 있다고 가정하기 때문입니다. 그 기여자들은 어떻게 의존성을 얻습니까? 항아리를 스스로 다운로드해야합니까? 그들이 올바른 버전을 다운로드했다는 것을 어떻게 알았습니까?!
방금 시작한 셀렉션 프로젝트는 지금 당분간 작업 해 온 개인 프로젝트이며, 내가 원하는 것을 가지고 있습니다. Selenium 2 WebDriver with Java. 또한 실제 회귀 시스템으로 실제 시나리오에서 구현 한 개념을 사용합니다.
새로운 것이므로 driver.findElement(blah).click()
을 사용하는 모든 종류의 예와 이와 같은 모든 종류의 추악한 것을 보셨을 것입니다. 이 프레임 워크는 특히 당신이 유창하게 부를 수있는 방법을 제공함으로써 모든 혼란으로부터 여러분을 추상화합니다.
이 프로젝트는 실제로 을 사용합니까?은 maven을 사용하며, Java와 함께 maven이 작동하는 방식과 좋은 프레임 워크를 제공하는 jUnit의 활성 예제를 볼 수 있습니다.
/**
* This is a sample test that can get you started.
* <br><br>
* This test shows how you can use the concept of "method chaining" to create successful, and independent tests, as well as the validations method that can get you started.
* @author ddavison
*
*/
@Config(url = "http://ddavison.github.io/tests/getting-started-with-selenium.htm", browser = Browser.FIREFOX) // You are able to specify a "base url" for your test, from which you will test. You may leave `browser` blank.
public class SampleFunctionalTest extends AutomationTest {
/**
* You are able to fire this test right up and see it in action. Right click the test() method, and click "Run As... jUnit test".
*
* The purpose of this is to show you how you can continue testing, just by taking the semi colon out, and continuing with your test.
*/
@Test
public void test() {
// click/validateAttribute
click(props.get("click"))
.validateAttribute(props.get("click"), "class", "success") // validate that the class indeed added.
// setText/validateText
.setText(By.id("setTextField"), "woot!")
.validateText(By.id("setTextField"), "woot!") // validates that it indeed set.
// check/uncheck
.check(By.id("checkbox"))
.validateChecked(By.id("checkbox")) // validate that it checked
.check(props.get("radio.2")) // remember that props come from <class name>.properties, and are always CSS selectors. (why use anything else, honestly.)
.validateUnchecked(props.get("radio.1")) // since radio 1 was selected by default, check the second one, then validate that the first radio is no longer checked.
// select from dropdowns.
.selectOptionByText(By.xpath("//select[@id='select']"), "Second") // just as a proof of concept that you can select on anything. But don't use xpath!!
.validateText(By.id("select"), "2") // validateText() will actually return the value="" attr of a dropdown, so that's why 2 works but "Second" will not.
.selectOptionByValue(By.cssSelector("select#select"), "3")
.validateText(props.get("select"), "3")
// frames
.switchToFrame("frame") // the id="frame"
.validatePresent(By.cssSelector("div#frame_content"))
// windows
.switchToWindow("Getting Started with Selenium") // switch back to the test window.
.click(By.linkText("Open a new tab/window"))
.waitForWindow("Google") // waits for the url. Can also be the you are expecting. :) (regex enabled too)
.setText(By.name("q"), "google!")
.closeWindow(); // we've closed google, and back on the getting started with selenium page.
}
}
간단한 -
다음은 프레임 워크에 포함 된 예입니다! 아니? 제공된이 프레임 워크에 도움이 필요하면 도움을 드릴 수 있습니다.
Ty 빠른 대답. ;) 방금 * "selenium-java-2.37.0.jar"파일을 classpath와 모든/lib jar 파일에 추가해야했습니다. – Jeflopo