TA的每日心情 | 开心 2017-4-12 10:17 |
---|
签到天数: 64 天 连续签到: 1 天 [LV.6]测试旅长
|
4#
楼主 |
发表于 2015-3-19 18:05:41
|
只看该作者
- package seliniumtest;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.ie.InternetExplorerDriver;
- import org.testng.annotations.AfterTest;
- import org.testng.annotations.BeforeTest;
- import org.testng.annotations.Test;
- import tools.Data;
- import tools.Tools;
- public class NewTest {
-
- WebDriver driver = new InternetExplorerDriver();
- @Test
- public void f() {
- Tools tool = new Tools();
- driver.get(Data.url);
-
- // 输入员工账号和密码
- tool.inputTextById(driver, "systemUserCode", Data.name);
- tool.inputTextById(driver, "password", Data.secret);
- }
- @BeforeTest
- public void beforeTest() {
- }
- @AfterTest
- public void afterTest() {
- }
- }
复制代码
- package tools;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- public class Tools {
- /*
- * 通过元素的Id锁定并点击按钮 elementId是所点击元素的Id,text是需要输入的内容
- */
- public void inputTextById(WebDriver driver, String elementId, String text) {
- WebElement input = driver.findElement(By.id(elementId));
- input.sendKeys(text);
- }
- }
复制代码 |
|