??????????????????????????????????????????????????????????Ч??????????????????????????????????????????á?????????????????£????????????????????

?????????????/????????????????к?????磬????????????QTP??Selenium????????????LoadRunner??JMeter????乤??????????????“??????”??“????????”?????“???????”???????“??????”???????γ?“???????”??

?????????????Щ??????????????????ж?????????????????Selenium??????з??????????????????????????????????????????????????????

????Selenium?????Web????????????????????????д????????????????????????????Web??y??к?в????????????????????????????????? ????????????????????????????????????????????????????????????????????磬RobotFramework??????????????Selenium??IDE??Remote Control?????RC????WebDriver??Grid???????????

?????? Selenium IDE

????????????????/??????????Firefox??????????????????????????Selenium RC????????Java??Ruby??C#??????????????????????????????????????????

?????? Selenium RC

????RC??Server??Client?????????????Server???????/??????????????HTTP??????????Web????Clinet???????????????????TestNG??JUnit??NUnit?????

?????? Selenium WebDriver

????WebDriver???Selenium2?????????????RC??????????API???????????RC?????????????????????????????????????????????????Server??

?????? Selenium Grid

??????Selenium??????????????????????????????????????????в??????ж??RC??WebDriver??????

????Selenium RC?????????????????“???”JS?????????????????????????Selenium WebDriver?????????????????????????????????????????WebDriver????????W3C?淶?????????Google??Mozilla????????????????

????WebDriver?淶????????????????????????????????????????????????????????????????????????Web??????????????WebDriver??????????findElement????????DOM????WebElement???????WebElement?????DOM??????в?????????????????????????????findElement?????????????λ????Locator?????ID??XPath??CSS????????????????????

????“WebDriver”?????????“Web?????????”?????????????????????????????????????????????????????????????????????????С???й???????δ????????????????ζ??????α??棬??????????????????????????????磬TestNG????????WebDriver??б??????????????

????????????“???????”?????????????WebDriver????“????”??“???”??????????????????????

????1????????б??????“????”???????????????????棺

????webDriver.findElement(By.xpath("//a[contains(@id??'addUserBtn')]//button")).click();

????????????

?????? By.xpath()??????XPath????λ???????

?????? click()???????????????????е????????

????2?????????????棬????“???”??“????”??“????”?????“???”??“????”??“????”???????“????”????????????б???棬???ж????????????


1)  String account="autotest2";
2)  webDriver.findElement(By.xpath("//div[contains(@id??'account_userForm')]//input")).sendKeys(account);
3)  webDriver.findElement(By.xpath("//div[contains(@id??'password_userForm')]//input")).sendKeys("1");
4)  webDriver.findElement(By.xpath("//div[contains(@id??'name_userForm')]//input")).sendKeys(account);
5)  webDriver.findElement(By.xpath("//div[contains(@id??'sex_userForm')]//input")).click();
6)  webDriver.findElement(By.xpath("//span[text()='?']")).click(); 
7)  webDriver.findElement(By.xpath("//div[contains(@id??'birthdate_userForm')]//input")).click();
8)  webDriver.findElement(By.xpath("//div[contains(@id??'nationality_userForm')]//input")).click();
9)  webDriver.findElement(By.xpath("//span[text()='?й?']")).click();    
10) webDriver.findElement(By.xpath("//a[contains(@id??'userSaveBtn')]//button")).click();       
11) WebElement ele = webDriver.findElement(By.xpath("//div[text()='"+account+"']"));   
12) Assert.assertNotNull(ele);