0

I'm trying to get the text from play.typeracer.com, but when i join a race, the page starts loading lots of things like ads. But altough the page is completely loaded Selenium waits for the Ads to load before it executes a code line.

I've already tried using a page load timeout, but as i said, the website is loaded, it just waits for the ads. The funny thing is, that on my normal browser the ads load instantly. But that could be because of the website cache.

Is there someway i can stop the additional page loading or just Find the Elements while it's loading?

VollRahm
  • 397
  • 1
  • 16

1 Answers1

0

My expectation is that you would need the combination of WebDriverWait and ExpectedConditions classes as it might be the case the element you're going to interact with will not be immediately available in DOM.

Suggested code to be used:

var wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(10));
var enterRace = wait
    .Until(SeleniumExtras.WaitHelpers.ExpectedConditions
    .ElementExists(By.XPath("//a[text()='Enter a typing race']")));
enterRace.Click();

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133