Selenium webdriver ?????-????λ
???????????? ???????[ 2013/12/24 16:51:00 ] ???????????????
????b??????????κ?????????λ???
????driver.findElement(By.cssSelector("?????[??????='?????']"));
????c????????????
^= driver.findElement(By.cssSelector("?????[??????^='xxx']")); ??????????xxx????????
$= driver.findElement(By.cssSelector("?????[??????$='xxx']")); ??????????xxx??β?????
*= driver.findElement(By.cssSelector("?????[??????^='xxx']")); ????????????xxx?????
|
????2????????+·????????????????????????????????????????????????????
????driver.findElement(By.cssSelector("div#login>input")) ?÷?????“div#login>input” ??????????·????λ??id?login??div?????????????????input??·????
???????????xpath??λ???????cssSelector??xpath??????????????λ??????????????????????????????????
????1?????·????λ???
????driver.findElement(By.xpath("/html/body/div/form/input"))
????2????????·????λ???
????driver.findElement(By.xpath("//input")) ???????????????????????????
????3???????????λ??????????????1?????????????????
????driver.findElement(By.xpath("//input[2]")) ???????????????????????????
????4??????????????λ???
????driver.findElement(By.xpath("//input[@id='username']"));
????driver.findElement(By.xpath("//img[@alt='flowr']"));
????5?????????????????????????λ????and??or
????driver.findElement(By.xpath("//input[@id='username' and @name='userID']"));
????6???????????????λ???
????driver.findElement(By.xpath("//input[@button]"))
????7????????cssSlector????ò??????????????
starts-with() driver.findElement(By.xpath("//input[stars-with(@id??'user')]"))
ends-with driver.findElement(By.xpath("//input[ends-with(@id??'name')]"))
contains() driver.findElement(By.xpath("//input[contains(@id??"ernam")]"))
|
????8????????????????????
????driver.findElement(By.xpath("//input[@*='username']"))
????9?????xpath??????λ???
????????????????w3school.com
???????????innerText??λ???
????1?????cssSelector????innerText??λ???
????driver.findElement(By.cssSelector("span[textContent='????']"));
????2?????xpath??text????
????driver.findElement(By.xpath("//span[contains(text()??'hello')]")) ???????
????driver.findElement(By.xpath("//span[text()='????']")) ???
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11