0

So something interesting is happening - unfortunately, I cannot post a url or something you guys can access, so maybe someone just has an idea of what the cause could be. I'd assume it would be something in development. Either way...

I have a test that logs in to an application, which will then load up a dashboard and search for some data. In Firefox, everything works fine. However, IE11 is having an issue once it logs in. So, Selenium works fine up until it loads the dashboard, where it will then find NOTHING. Not even "//html". It gives the basic element not found error. I'm assuming the developers have written something that prevents access, but the one I talked to wasn't sure.

Any idea of what could be causing this so that I could go suggest something to the developers? Again, this doesn't happen in Firefox, which could also suggest something's up with IE11 (though Selenium works fine on other applications and up until the Dashboard screen on this one). If you need more information, let me know - just be aware that I might not have much to give.

A couple things to note:

1.  it is https protocol, but so is the login page
2.  at the end of the url bar, it says there is a certificate error that will not go away 
no matter what I do (I have added the supposedly correct certificates).

What I'm using:

Selenium 2.4.5
32 bit IEDriverServer
Python 2.7.8
IE11 (other IE versions are not supported, so I cannot compare)
Windows 7

EDIT:

I talked with a developer, and the best thing he could think of was the fact that the dashboard heavily uses polyfills, and that maybe that is the reason that Selenium isn't finding anything. With that being said, is there a way to find elements using Selenium when polyfills are involved? Or is Selenium just not going to work for it.

MORE:

Here is some code that equivalent to what my test would do. Assume that every exception would normally be caught and wouldn't kill the script...

from pdb import set_trace
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver

url = 'server.url'

capabilities = webdriver.DesiredCapabilities().INTERNETEXPLORER
capabilities['acceptSslCerts'] = True

# use path due to having both a 64 bit and 32 bit version of the driver - specifies which to use
driver = webdriver.Ie("path-to-iedriver.exe", capabilities=capabilities)
driver.maximize_window()
driver.get("https://%s" % url)

# click ie's continue to website
driver.get("javascript:document.getElementById('overridelink').click();")
time.sleep(1)

# clicks 'I Agree' on a page before login
driver.find_element_by_xpath("//button[text()='I Agree']").click()
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'username')))

# logs in
driver.find_element_by_id("username").send_keys("username")
driver.find_element_by_name("j_password").send_keys("password")
driver.find_element_by_xpath("//button[contains(text(), 'Log on')]").click()

# click continue when a successful login box pops up
ret = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.ID, "continueBtn")))
ret.click()

# this waits for an element on the dashboard page - it will fail
WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.XPATH, "//span[contains(text(), 'banner')]")))

# everything from here on will fail due to element not found (only in IE)
driver.find_element_by_xpath("//html")
driver.find_element_by_xpath("anything")

set_trace()

Again, the elements will be found in Firefox and Chrome, but not IE.

user2869231
  • 1,431
  • 5
  • 24
  • 53

1 Answers1

0

You might need to add an Explicit Wait to wait for the data to be loaded. For example, you may wait for a specific element to become present:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "myDynamicElement"))
)

# proceed with locating the elements containing the desired data

Old answer

It sounds like this is a certificate issue, print out the .title and the .page_source once the page is loaded and check what is there.

You can also let it accept the certificate by setting acceptSslCerts desired capability to True:

from selenium import webdriver

capabilities = webdriver.DesiredCapabilities().INTERNETEXPLORER
capabilities['acceptSslCerts'] = True

driver = webdriver.Ie(capabilities=capabilities)
# ...

Also see:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • hmm. .title returns "Dashboard", and .page_source returns... a lot of stuff. I tried the desired capabilities code and it didn't change anything :/ – user2869231 Sep 25 '15 at 16:35
  • @user2869231 okay, at least we know it is not about the certificate. Good, I've updated the answer and added one more thing to try. Could you show me the code you are executing? (add it to the question please) – alecxe Sep 25 '15 at 17:05
  • I actually already have a wait, and have it open up debug (pdb's set_trace) when it loads the dashboard (after it fails...). With that being said, loading time shouldn't be the issue. Also, I built my own framework, so let me write an equivalent script that'll just do what my test does – user2869231 Sep 25 '15 at 18:32
  • added a sample script – user2869231 Sep 25 '15 at 18:53
  • @user2869231 okay, thank you, that helps. So, the logging in part works and you'll get the "continue" button - aren't you supposed to click it?..currently you are not actually clicking it..this might be non-relevant or just a problem with this example though. Thanks. – alecxe Sep 25 '15 at 19:02
  • oops - I must've deleted it when I was formatting it. And yes, the login works and so does clicking the button. It's once the dashboard loads where nothing can be found. I can still tell Selenium to change to a different url, it just won't find any elements on the dashboard page – user2869231 Sep 25 '15 at 19:52
  • @user2869231 yeah, it looks related to polyfills. Can you print out the `source_code` of the dashboard page loaded in IE and paste it into the question (without any sensitive data please)? Thanks. – alecxe Sep 28 '15 at 16:23
  • Let me see if I can get that for you – user2869231 Sep 29 '15 at 14:26
  • yeah, that's a no go, sorry – user2869231 Sep 29 '15 at 16:21