0

I know that driver.getPageSource() gets you the web page as Html but the issue I am having is that the site I am testing puts data in brackets like {{OriginDescription}}, maybe using some js framework to get the data? Anyway I can view the data when I inspect the element in browser but viewing the page source in browser also shows only the brackets and not the data. So how do I get the webpage as it is when I am viewing (inspect) it in the browser?

Below is the website I am testing to be exact:

driver.get("https://www.united.com/ual/en/US/flight-search/book-a-flight/results/rev?f=Miami,+FL,+US+(MIA+-+All+Airports)&t=IAH&d=2020-05-02&r=2020-05-16&sc=7,7&px=1&taxng=1&newHP=True&idx=1"); String pageSource = driver.getPageSource(); 

I am using java and chromedriver.

    1 Answer 1

    0

    Try waiting for an element to load first, you can do that using:

    driver.get("url"); WebDriverWait wait = new WebDriverWait(driver, TIME_IN_SECONDS); wait.until(ExpectedConditions.elementToBeClickable(By.className("element-class-name"))); String page = driver.getPageSource(); 

    This would wait for a page to complete loading and check is the element is clickable. Or, you can wait until the element is visible:

    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("element-id"))); 

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.