Selenium cant find this xpath I tried every way I need to click last button Deactivate but I cant
I tried xpath,cssSelectors,
@When("^I click deactivate button$")
public void iClickDeactivateButton(){
WebElement deactivateBatchButton = driver.findElement(By.xpath("//BUTTON[@_ngcontent-c14=''][text()='Deactivate'][text()='Deactivate']/self::BUTTONclass='deactivate']"));
deactivateBatchButton.click();
}
I want to click this button and carry one rest of the tests.
As the desired element is a Angular element and to locate it you have to induce WebDriverWait and you can use either of the following solutions:
cssSelector
:
WebElement deactivateBatchButton = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.deactivate.xh-highlight")));
xpath
:
WebElement deactivateBatchButton = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='deactivate xh-highlight' and text()='Deactivate']")));
You can carry on with the button name.
WebElement deactivateBatchButton = driver.findElement(By.xpath("//*[text()='Deactivate']"));
deactivateBatchButton.click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.