-
HTML
tagName{}
idValue{}
.ClassValue{}
-
JavaScript
- document.getElementBy(id Name tagName ClassName)
-
JAVA
- getElementBy(id Name className xpath)
xpath寫法:
- getElementBy(id Name className xpath)
driver.findElement(
By.xpath("http://input[@id='alertButtonId' and @type='button']"));
通過xpath定位,xpath定位有N種寫法,這里列幾個(gè)常用寫法:
driver.findElement(By.xpath("http://*[@id='kw']"))
driver.findElement(By.xpath("http://*[@name='wd']"))
driver.findElement(By.xpath("http://input[@class='s_ipt']"))
driver.findElement(By.xpath("/html/body/form/span/input"))
driver.findElement(By.xpath("http://span[@class='soutu-btn']/input"))
driver.findElement(By.xpath("http://form[@id='form']/span/input"))
driver.findElement(By.xpath("http://input[@id='kw' and @name='wd']"))