问题
I'm looking for a way to have selenium webdriver wait until the text present in the element location I'm interested is NOT the string provided in the code below.
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//*[@id=\"order-details\"]/div[2]/div/dl/dd[1]/div"),"Completed successfully"));
I'm looking for a way where the "text to be present" is not "Completed successfully" so that the code can move forward and no longer wait
回答1:
You can try with ExpectedConditions - not
WebElement element = driver.findElement(By.xpath("//*[@id=\"order-details\"]/div[2]/div/dl/dd[1]/div"));
wait.until(ExpectedConditions.not(ExpectedConditions.textToBePresentInElement(element, "Completed successfully")));
来源:https://stackoverflow.com/questions/57101845/waiting-until-text-to-be-present-in-element-is-not-the-string-provided