[英]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.