Trying to get numeric dynamic text value from span element. My test is data driven so for each run it needs to get text (dollar amount) from web page and then compare it to expected value in excel. For some reason my code doesn't work. Please help to solve.
My HTML:
$ 445.87My Locator: By PRICE = By.xpath("//div[@class='price ng-binding'][@ng-hide='calc.isCalculating']/text()");
My Code:
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.presenceOfElementLocated(PRICE));
WebElement actualPriceElm = driver.findElement(PRICE);
actualPriceElm.getText();
Assert.assertEquals(actualPriceElm, strExpectedPrice);
My Error: Timed out after 15 seconds waiting for presence of element located by: By.xpath: //div[@class='price ng-binding'][@ng-hide='calc.isCalculating']/text()
When I use my xpath without "/text()" like this //div[@class='price ng-binding'][@ng-hide='calc.isCalculating'] then I get following error:
Exception in thread "main" java.lang.AssertionError: expected [445.87] but found [[[FirefoxDriver: firefox on WINDOWS (f26e0c00-823f-4d45-8285-014303527524)] -> xpath: //div[@class='price ng-binding'][@ng-hide='calc.isCalculating']]]
By.CssSelector()- vkrams