5295

How to make Selenium WebDriver not to wait for whole page to load

I am using python 2.7 with Selenium webdriver for Firefox and I have a problem I can't solve or find solved on the internet. My task is to open around 10k web pages (adsl router web interfaces - via ip address) and upload new firmware. I wrote the code but in order to finish it I must learn how to make selenium webdriver not to wait for page load like forever, but to wait for 2 minutes(it is time needed for new firmware to upload) and then proceed to next step. I thought I let it wait for forever (wait for router to reconnect - much slower but doable by me without help) but the catch is when I click upload button it takes 2 minutes of uploading new firmware, then router reboots to apply changes (takes less then 2 minutes), then tries to connect (around 10 seconds) and even then if it gets some other IP it will never load and my program wait for forever. So, I want to skip all of that and I want program to proceed to next router after first 2 minutes. Can it be done? I read something about "pageLoadingStrategy" but I couldn't understand how to use it. Please write me if it is not understandable, because English is not my native language. Below you can see the code sample, after button.submit() it should wait for 2 minutes and proceed and not wait forever:

def firmware_upload(): global ip br.get("http://"+ip+"/upload.html") button = br.find_element_by_xpath('//input[@type="file" and @name="filename"]') button.send_keys("/home/djura/Downloads/KW5815A_update_140417") button.submit() print ("Odradjen UPDATE SOFTWARE-a!") return

Answer1:

The problem is probably because you are using button.submit, which if I'm not mistaken waits for the return of the action. So instead you should find the <strong>actual submit button</strong> and click on it using click, e.g.

submit_button = br.find_element_by_id('SUBMIT_BTN_ID') submit_button.click()

P.S. the fact that in your example code your button variable actually refers to an input element is misleading.

Answer2:

see if this works.

try { br.manage().timeouts().pageLoadTimeout(2, TimeUnit.MINUTES); global ip br.get("http://"+ip+"/upload.html") button = br.find_element_by_xpath('//input[@type="file" and @name="filename"]') button.send_keys("/home/djura/Downloads/KW5815A_update_140417") button.submit() print ("Odradjen UPDATE SOFTWARE-a!") return } catch(TimeoutException e) { print("2min over"); }

Recommend

  • PuTTy “unknown option -o” when trying to connect
  • ORA-04061: existing state of package body “PACKAGE.NAME” has been invalidated persists
  • Apache not working after Windows 8.1 upgrade [closed]
  • Webdriver Xpath Performance
  • Why are Pickle files in Pickle protocol 4 twice as large as those in protocol 3 without having any g
  • OpenMP for dependent variables
  • How do I retrieve the text in a table column using Selenium RC?
  • How to capture or listen to browser notifications?
  • IllegalArgumentException caught when parsing URL with JSON String
  • Can you use multiple instances of Edge on a Selenium Grid Node?
  • Paramiko SSHException Channel Closed
  • Parallel sieve of Eratosthenes - Java Multithreading
  • Classic ASP URL Rewriting
  • How do you create a Fuseki SPARQL server using the Apache Jena Java API?
  • How can I tell a form not to dispose a particular control when it closes?
  • joining two bezier curves
  • Hash Code in SQL Server?
  • Multiple producers single consumer locking schema
  • what makes a request a new request in asp.net C#
  • Debugging VB6 Code From Visual Studio 2010
  • Selenium to click on a javascript button corresponding to a text
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Reading a file into a multidimensional array
  • Read text file that is not in the main package in a runnable jar
  • Object and struct member access and address offset calculation
  • Diff between two dataframes in pandas
  • Code in Job's Script Block after Start-Process Does not Execute
  • Hardware Accelerated Image Scaling in windows using C++
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • jQuery show() function is not executed in Safari if submit handler returns true
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Does CUDA 5 support STL or THRUST inside the device code?
  • htaccess rewriting URLs with multiple forward slashes
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • A cron job substitute?
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]