How to make selenium wait before getting contents from the actual website which loads after the landing page...












1















driver = webdriver.Ie("C:\IEDriverServer.exe")
driver.get(testurl)
driver.refresh()
time.sleep(5)
data = driver.find_element_by_id("__content0-value-scr")


So I'm trying to find an element by it's id using Selenium (Python) and Internet Explorer, because I'm limited to Internet Explorer due to company regulations.



My problem is as follows:
on driver.get(testurl), selenium loads the page but IE first starts up with the IEDriver landing page.
Only after that, it loads the requested url.



The problem here is that Selenium recognizes the IE Driver landing page as the url to be loaded and therefore ignores the page I want to search on, which gets loaded after that.



Has anyone got an idea on how to work around this?










share|improve this question

























  • What exactly do you mean by Selenium recognizes the IE Driver landing page as the url to be loaded? Also why do you use driver.refresh() right after driver.get(testurl)?

    – Andersson
    Nov 22 '18 at 21:44











  • In ´data = driver.find_element_by_id....´ , selenium does not find the requested id, because it searches the IE Driver Server landing page for this id. I used ´driver.refresh()´ to try and get selenium to load the page I need instead of the IE Driver Server landing page.

    – the dood
    Nov 22 '18 at 21:48













  • Why do you think so? There are several reasons not to find element on page

    – Andersson
    Nov 22 '18 at 21:48













  • Because it worked on a test machine with the firefox webdriver which means that there is not an issue with the connection or incorrect page loading.

    – the dood
    Nov 22 '18 at 21:50






  • 1





    Could you use the WebDriverWait method to wait for something on the landing page before you do the driver.get()?

    – John Anderson
    Nov 22 '18 at 21:54
















1















driver = webdriver.Ie("C:\IEDriverServer.exe")
driver.get(testurl)
driver.refresh()
time.sleep(5)
data = driver.find_element_by_id("__content0-value-scr")


So I'm trying to find an element by it's id using Selenium (Python) and Internet Explorer, because I'm limited to Internet Explorer due to company regulations.



My problem is as follows:
on driver.get(testurl), selenium loads the page but IE first starts up with the IEDriver landing page.
Only after that, it loads the requested url.



The problem here is that Selenium recognizes the IE Driver landing page as the url to be loaded and therefore ignores the page I want to search on, which gets loaded after that.



Has anyone got an idea on how to work around this?










share|improve this question

























  • What exactly do you mean by Selenium recognizes the IE Driver landing page as the url to be loaded? Also why do you use driver.refresh() right after driver.get(testurl)?

    – Andersson
    Nov 22 '18 at 21:44











  • In ´data = driver.find_element_by_id....´ , selenium does not find the requested id, because it searches the IE Driver Server landing page for this id. I used ´driver.refresh()´ to try and get selenium to load the page I need instead of the IE Driver Server landing page.

    – the dood
    Nov 22 '18 at 21:48













  • Why do you think so? There are several reasons not to find element on page

    – Andersson
    Nov 22 '18 at 21:48













  • Because it worked on a test machine with the firefox webdriver which means that there is not an issue with the connection or incorrect page loading.

    – the dood
    Nov 22 '18 at 21:50






  • 1





    Could you use the WebDriverWait method to wait for something on the landing page before you do the driver.get()?

    – John Anderson
    Nov 22 '18 at 21:54














1












1








1








driver = webdriver.Ie("C:\IEDriverServer.exe")
driver.get(testurl)
driver.refresh()
time.sleep(5)
data = driver.find_element_by_id("__content0-value-scr")


So I'm trying to find an element by it's id using Selenium (Python) and Internet Explorer, because I'm limited to Internet Explorer due to company regulations.



My problem is as follows:
on driver.get(testurl), selenium loads the page but IE first starts up with the IEDriver landing page.
Only after that, it loads the requested url.



The problem here is that Selenium recognizes the IE Driver landing page as the url to be loaded and therefore ignores the page I want to search on, which gets loaded after that.



Has anyone got an idea on how to work around this?










share|improve this question
















driver = webdriver.Ie("C:\IEDriverServer.exe")
driver.get(testurl)
driver.refresh()
time.sleep(5)
data = driver.find_element_by_id("__content0-value-scr")


So I'm trying to find an element by it's id using Selenium (Python) and Internet Explorer, because I'm limited to Internet Explorer due to company regulations.



My problem is as follows:
on driver.get(testurl), selenium loads the page but IE first starts up with the IEDriver landing page.
Only after that, it loads the requested url.



The problem here is that Selenium recognizes the IE Driver landing page as the url to be loaded and therefore ignores the page I want to search on, which gets loaded after that.



Has anyone got an idea on how to work around this?







python selenium internet-explorer webdriverwait selenium-iedriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 7:09









DebanjanB

41.6k83979




41.6k83979










asked Nov 22 '18 at 21:31









the doodthe dood

911210




911210













  • What exactly do you mean by Selenium recognizes the IE Driver landing page as the url to be loaded? Also why do you use driver.refresh() right after driver.get(testurl)?

    – Andersson
    Nov 22 '18 at 21:44











  • In ´data = driver.find_element_by_id....´ , selenium does not find the requested id, because it searches the IE Driver Server landing page for this id. I used ´driver.refresh()´ to try and get selenium to load the page I need instead of the IE Driver Server landing page.

    – the dood
    Nov 22 '18 at 21:48













  • Why do you think so? There are several reasons not to find element on page

    – Andersson
    Nov 22 '18 at 21:48













  • Because it worked on a test machine with the firefox webdriver which means that there is not an issue with the connection or incorrect page loading.

    – the dood
    Nov 22 '18 at 21:50






  • 1





    Could you use the WebDriverWait method to wait for something on the landing page before you do the driver.get()?

    – John Anderson
    Nov 22 '18 at 21:54



















  • What exactly do you mean by Selenium recognizes the IE Driver landing page as the url to be loaded? Also why do you use driver.refresh() right after driver.get(testurl)?

    – Andersson
    Nov 22 '18 at 21:44











  • In ´data = driver.find_element_by_id....´ , selenium does not find the requested id, because it searches the IE Driver Server landing page for this id. I used ´driver.refresh()´ to try and get selenium to load the page I need instead of the IE Driver Server landing page.

    – the dood
    Nov 22 '18 at 21:48













  • Why do you think so? There are several reasons not to find element on page

    – Andersson
    Nov 22 '18 at 21:48













  • Because it worked on a test machine with the firefox webdriver which means that there is not an issue with the connection or incorrect page loading.

    – the dood
    Nov 22 '18 at 21:50






  • 1





    Could you use the WebDriverWait method to wait for something on the landing page before you do the driver.get()?

    – John Anderson
    Nov 22 '18 at 21:54

















What exactly do you mean by Selenium recognizes the IE Driver landing page as the url to be loaded? Also why do you use driver.refresh() right after driver.get(testurl)?

– Andersson
Nov 22 '18 at 21:44





What exactly do you mean by Selenium recognizes the IE Driver landing page as the url to be loaded? Also why do you use driver.refresh() right after driver.get(testurl)?

– Andersson
Nov 22 '18 at 21:44













In ´data = driver.find_element_by_id....´ , selenium does not find the requested id, because it searches the IE Driver Server landing page for this id. I used ´driver.refresh()´ to try and get selenium to load the page I need instead of the IE Driver Server landing page.

– the dood
Nov 22 '18 at 21:48







In ´data = driver.find_element_by_id....´ , selenium does not find the requested id, because it searches the IE Driver Server landing page for this id. I used ´driver.refresh()´ to try and get selenium to load the page I need instead of the IE Driver Server landing page.

– the dood
Nov 22 '18 at 21:48















Why do you think so? There are several reasons not to find element on page

– Andersson
Nov 22 '18 at 21:48







Why do you think so? There are several reasons not to find element on page

– Andersson
Nov 22 '18 at 21:48















Because it worked on a test machine with the firefox webdriver which means that there is not an issue with the connection or incorrect page loading.

– the dood
Nov 22 '18 at 21:50





Because it worked on a test machine with the firefox webdriver which means that there is not an issue with the connection or incorrect page loading.

– the dood
Nov 22 '18 at 21:50




1




1





Could you use the WebDriverWait method to wait for something on the landing page before you do the driver.get()?

– John Anderson
Nov 22 '18 at 21:54





Could you use the WebDriverWait method to wait for something on the landing page before you do the driver.get()?

– John Anderson
Nov 22 '18 at 21:54












1 Answer
1






active

oldest

votes


















2














When you use Selenium, IEDriverServer and Internet Explorer, while IEDriverServer initiates a new IE Browser session, IE Browser first starts up with the IEDriver landing page and then loads the requested url.



Incase Selenium recognizes the IEDriverServer's landing page as the url to be loaded, in that case the solution would be to induce WebDriverWait for the Page Title to be equivalent to the actual page title of the AUT (Application Under Test).





  • Code Block:



    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    testurl = "https://www.facebook.com/" # replace with the url of the AUT
    driver = webdriver.Ie(executable_path=r'C:pathtoIEDriverServer.exe')
    driver.get(testurl)
    WebDriverWait(driver, 10).until(EC.title_contains("Facebook")) # # replace with the title of the AUT
    data = driver.find_element_by_id("__content0-value-scr")







share|improve this answer



















  • 1





    This works for me, thank you very much!

    – the dood
    Nov 26 '18 at 10:42











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438182%2fhow-to-make-selenium-wait-before-getting-contents-from-the-actual-website-which%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














When you use Selenium, IEDriverServer and Internet Explorer, while IEDriverServer initiates a new IE Browser session, IE Browser first starts up with the IEDriver landing page and then loads the requested url.



Incase Selenium recognizes the IEDriverServer's landing page as the url to be loaded, in that case the solution would be to induce WebDriverWait for the Page Title to be equivalent to the actual page title of the AUT (Application Under Test).





  • Code Block:



    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    testurl = "https://www.facebook.com/" # replace with the url of the AUT
    driver = webdriver.Ie(executable_path=r'C:pathtoIEDriverServer.exe')
    driver.get(testurl)
    WebDriverWait(driver, 10).until(EC.title_contains("Facebook")) # # replace with the title of the AUT
    data = driver.find_element_by_id("__content0-value-scr")







share|improve this answer



















  • 1





    This works for me, thank you very much!

    – the dood
    Nov 26 '18 at 10:42
















2














When you use Selenium, IEDriverServer and Internet Explorer, while IEDriverServer initiates a new IE Browser session, IE Browser first starts up with the IEDriver landing page and then loads the requested url.



Incase Selenium recognizes the IEDriverServer's landing page as the url to be loaded, in that case the solution would be to induce WebDriverWait for the Page Title to be equivalent to the actual page title of the AUT (Application Under Test).





  • Code Block:



    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    testurl = "https://www.facebook.com/" # replace with the url of the AUT
    driver = webdriver.Ie(executable_path=r'C:pathtoIEDriverServer.exe')
    driver.get(testurl)
    WebDriverWait(driver, 10).until(EC.title_contains("Facebook")) # # replace with the title of the AUT
    data = driver.find_element_by_id("__content0-value-scr")







share|improve this answer



















  • 1





    This works for me, thank you very much!

    – the dood
    Nov 26 '18 at 10:42














2












2








2







When you use Selenium, IEDriverServer and Internet Explorer, while IEDriverServer initiates a new IE Browser session, IE Browser first starts up with the IEDriver landing page and then loads the requested url.



Incase Selenium recognizes the IEDriverServer's landing page as the url to be loaded, in that case the solution would be to induce WebDriverWait for the Page Title to be equivalent to the actual page title of the AUT (Application Under Test).





  • Code Block:



    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    testurl = "https://www.facebook.com/" # replace with the url of the AUT
    driver = webdriver.Ie(executable_path=r'C:pathtoIEDriverServer.exe')
    driver.get(testurl)
    WebDriverWait(driver, 10).until(EC.title_contains("Facebook")) # # replace with the title of the AUT
    data = driver.find_element_by_id("__content0-value-scr")







share|improve this answer













When you use Selenium, IEDriverServer and Internet Explorer, while IEDriverServer initiates a new IE Browser session, IE Browser first starts up with the IEDriver landing page and then loads the requested url.



Incase Selenium recognizes the IEDriverServer's landing page as the url to be loaded, in that case the solution would be to induce WebDriverWait for the Page Title to be equivalent to the actual page title of the AUT (Application Under Test).





  • Code Block:



    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    testurl = "https://www.facebook.com/" # replace with the url of the AUT
    driver = webdriver.Ie(executable_path=r'C:pathtoIEDriverServer.exe')
    driver.get(testurl)
    WebDriverWait(driver, 10).until(EC.title_contains("Facebook")) # # replace with the title of the AUT
    data = driver.find_element_by_id("__content0-value-scr")








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 7:11









DebanjanBDebanjanB

41.6k83979




41.6k83979








  • 1





    This works for me, thank you very much!

    – the dood
    Nov 26 '18 at 10:42














  • 1





    This works for me, thank you very much!

    – the dood
    Nov 26 '18 at 10:42








1




1





This works for me, thank you very much!

– the dood
Nov 26 '18 at 10:42





This works for me, thank you very much!

– the dood
Nov 26 '18 at 10:42


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438182%2fhow-to-make-selenium-wait-before-getting-contents-from-the-actual-website-which%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin