2013-10-31 3 views
2

저는 Selenium Webdriver 프로젝트를 만들려고 노력하는 완전한 초보자입니다. ChromeDriver 또는 HTMLUnitDriver로 생각합니다. 내가 틀렸다면 말해줘. netbeans에서 Maven 프로젝트를 생성하여 Selenium Webdriver 프로젝트를 설정하고 의존성을 다운로드하도록 pom.xml 파일을 구성하는 방법을 읽었습니다. 그러나 현재 어디에서 시작할지, 또는 Maven을 올바르게 구성하는 방법을 알지 못합니다.Eclipse 또는 Maven없이 Selenium 프로젝트 설정 정보

내 생각에 ... 메이븐은 필수입니까? Selenium 프로젝트를 만들려면 Maven을 처리해야합니다. 라이브러리 (http://www.seleniumhq.org/download/)를 다운로드하고이를 "전역 라이브러리"섹션에 포함시킨 다음 라이브러리를 프로젝트 "libraries"폴더에 추가하고 가져 오기 절을 사용하여 하나의 패키지 또는 다른 패키지를 사용할 수 있습니까?

답변

1

필수 사항인가요?

아니요! 그렇지 않다.

라이브러리를 다운로드하여 포함시킬 수 있습니까?

예 가능합니다!

Maven도 똑같이 할 것입니다! (단순화 된) 모든 jar가 포함 된 라이브러리를 생성하고이를 프로젝트에 추가합니다.

+0

Ty 빠른 대답. ;) 방금 * "selenium-java-2.37.0.jar"파일을 classpath와 모든/lib jar 파일에 추가해야했습니다. – Jeflopo

2

대단원! 초심자 인 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. 

    } 
} 

간단한 -

다음은 프레임 워크에 포함 된 예입니다! 아니? 제공된이 프레임 워크에 도움이 필요하면 도움을 드릴 수 있습니다.

관련 문제