title: Waiting for IE's "This page can't be displayed" Page
body: <p>I'm trying to create an explicit wait with Selenium that waits for the visibility of the "This page can't be displayed" message in Internet Explorer when a page cannot be reached.  Selenium, of course, has a problem with the apostrophe in xpaths.  The code I'm working with is the following ...</p>
  
  <pre><code>String expectedText = "This page can't be displayed";
  String waitforXpath = "//div[contains(.,'"+expectedText+"')]";
  WebDriverWait wait = new WebDriverWait(driver,10);
  wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(waitforXpath)));
  </code></pre>
  
  <p>But of course, Selenium throws a TimeoutException waiting on the visibility of the "This page can't be displayed" element.  Any suggestions as to how to best work around this?</p>
  
  <p><strong>EDIT:</strong>  Here is the source for that page ...</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;link rel="stylesheet" type="text/css" href="NewErrorPageTemplate.css" &gt;
  
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;This page can't be displayed&lt;/title&gt;
  
      &lt;script src="errorPageStrings.js" language="javascript" type="text/javascript"&gt;
      &lt;/script&gt;
      &lt;script src="httpErrorPagesScripts.js" language="javascript" type="text/javascript"&gt;
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onLoad="javascript:getInfo();"&gt;
      &lt;div id="contentContainer" class ="mainContent"&gt;
          &lt;div id="mainTitle" class="title"&gt;This page can't be displayed&lt;/div&gt;
          &lt;div class="taskSection" id="taskSection"&gt;
              &lt;ul id="cantDisplayTasks" class="tasks"&gt;
                  &lt;li id="task1-1"&gt;Make sure the web address &lt;span id="webpage" class="webpageURL"&gt;&lt;/span&gt;is correct.&lt;/li&gt;
                  &lt;li id="task1-2"&gt;Look for the page with your search engine.&lt;/li&gt;
                  &lt;li id="task1-3"&gt;Refresh the page in a few minutes.&lt;/li&gt;
              &lt;/ul&gt;
              &lt;ul id="notConnectedTasks" class="tasks" style="display:none"&gt;
                  &lt;li id="task2-1"&gt;Check that all network cables are plugged in.&lt;/li&gt;
                  &lt;li id="task2-2"&gt;Verify that airplane mode is turned off.&lt;/li&gt;
                  &lt;li id="task2-3"&gt;Make sure your wireless switch is turned on.&lt;/li&gt;
                  &lt;li id="task2-4"&gt;See if you can connect to mobile broadband.&lt;/li&gt;
                  &lt;li id="task2-5"&gt;Restart your router.&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
          &lt;div&gt;&lt;button id="diagnose" class="diagnoseButton" onclick="javascript:diagnoseConnectionAndRefresh(); return false;"&gt;Fix connection problems&lt;/button&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>