簡體   English   中英

Selenium:如何使用web Driver設置selenium

[英]Selenium: how to set up selenium with web Driver

我是用網絡驅動程序編寫硒測試用例的新手。

請讓我知道如何設置我的測試用例。

注意:我不想使用Selenium IDE。

謝謝

您可以使用selenium webdriver從您的代碼驅動瀏覽器。啟動firefox驅動程序,因為您不需要任何設置。對於其他瀏覽器,如chrome,即您需要設置驅動程序。您可以在這里開始:

http://seleniumhq.org/docs/03_webdriver.html#introducing-the-selenium-webdriver-api-by-example

HTH

自己完成了設置..謝謝

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:testContextWeb.xml"})
public class SeleniumTest {

WebDriver driver;

@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
}

@After
public void tearDown() throws Exception {
    driver.close();
}

@Test
public void testCase() throws Exception {
    //open the event page
    driver.get("https://websiteAddress/Context");


    driver.findElement(By.xpath(".//*[@id='username']")).sendKeys("someUserName");
    driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("xxxx"); // "xxxx" means some password

 }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM