我可以在以下位置使用什么定位器:
<button class="buttonLeftEnabled floatLeft" type="submit"><span>Continue</span></button>
答案 0 :(得分:3)
要找到“继续”按钮,可以使用:
driver.findElement(By.xpath("//button[@type='submit']").click();
OR
driver.findElement(By.xpath("//button[@contains(text(),'Continue')]").click();
希望这会有所帮助。
答案 1 :(得分:0)
要找到文本为继续的按钮,可以使用以下任一解决方案:
cssSelector
:
WebElement elem = driver.findElement(By.cssSelector("button.buttonLeftEnabled.floatLeft>span")).click();
xpath
:
WebElement elem = driver.findElement(By.xpath("//button[@class='buttonLeftEnabled floatLeft']/span[contains(.,'Continue')]")).click();