-
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("//input[@id='alertButtonId' and @type='button']"));
通过xpath定位,xpath定位有N种写法,这里列几个常用写法:
driver.findElement(By.xpath("//*[@id='kw']"))
driver.findElement(By.xpath("//*[@name='wd']"))
driver.findElement(By.xpath("//input[@class='s_ipt']"))
driver.findElement(By.xpath("/html/body/form/span/input"))
driver.findElement(By.xpath("//span[@class='soutu-btn']/input"))
driver.findElement(By.xpath("//form[@id='form']/span/input"))
driver.findElement(By.xpath("//input[@id='kw' and @name='wd']"))