How to stop page loading using selenium-web driver?

How to stop page loading using selenium-web driver?

require ‘selenium-webdriver’
require ‘win32ole’

driver = Selenium::WebDriver.for :firefox
driver.get “https://example.com/

Say after sleep(10), I want to stop the loading of the page.Because the
page is taking too long time to load.

Any chance to do that using selenium-web driver?

Thanks

Getting the below error:

C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in rescue in rbuf_fill': Timeout: :Error (Timeout::Error) from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:inrbuf_fill’
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in
readuntil' from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:inreadline’
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in
read_status_line' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:inread_new’
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in block in transport_r equest' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:incatch’
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in
transport_request' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:inrequest’
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1286:in block in request' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:instart’
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:in request' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s elenium/webdriver/remote/http/default.rb:83:inresponse_for’
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s
elenium/webdriver/remote/http/default.rb:39:in request' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s elenium/webdriver/remote/http/common.rb:40:incall’
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s
elenium/webdriver/remote/bridge.rb:615:in raw_execute' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s elenium/webdriver/remote/bridge.rb:593:inexecute’
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s
elenium/webdriver/remote/bridge.rb:561:in find_element_by' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2/lib/s elenium/webdriver/common/search_context.rb:42:infind_element’
from C:/Documents and Settings/rakshiar/My
Documents/userdata/Ruby/Scrip
ts/answerlist.rb:29:in rescue in <main>' from C:/Documents and Settings/rakshiar/My Documents/userdata/Ruby/Scrip ts/answerlist.rb:21:in

Joel P. wrote in post #1095134:

require ‘selenium-webdriver’
require ‘timeout’

driver = Selenium::WebDriver.for :firefox
Timeout.timeout(10) do
driver.get “https://example.com/
end

Regarding your exception, look at line 21 in answerlist.rb. That’s
failing.

Not working- Is there anyway to stop page load?

require ‘selenium-webdriver’
require ‘timeout’

driver = Selenium::WebDriver.for :firefox
Timeout.timeout(10) do
driver.get “https://example.com/
end

Regarding your exception, look at line 21 in answerlist.rb. That’s
failing.

Do you get any response from that submit if you locate and click it as a
button?

Joel P. wrote in post #1095143:

Do you get any response from that submit if you locate and click it as a
button?

After clicking on a submit, it’s bringing me to the correct page,but
browser is showing “Loading Loading… loading…” after that error
has been thrown and the browser still loading,after a long while - I can
see that the page is loaded.

Thanks

require ‘rubygems’
require ‘selenium-webdriver’
require ‘win32ole’

driver = Selenium::WebDriver.for :firefox
driver.manage.timeouts.implicit_wait = 10
driver.get “https://prod.example.com/

element = driver.find_element :name => “j_username”
element.send_keys “####”
element = driver.find_element :name => “j_password”
element.send_keys “#####”
driver.find_element(:name, “login”).submit #<== from here the code went
to forever loading and after that thrown error.Not reaching to the below
statement. tried also - “driver.manage.timeouts.implicit_wait = 10”. But
no result.

driver.find_element(:link_text, “employelink”).click

Love U Ruby wrote in post #1095142:

require ‘rubygems’
require ‘selenium-webdriver’
require ‘win32ole’

driver = Selenium::WebDriver.for :firefox
driver.manage.timeouts.implicit_wait = 10

Here should I need to put this - "driver.manage.timeouts.page_load

= 180"?######

driver.get “https://prod.example.com/

element = driver.find_element :name => “j_username”
element.send_keys “####”
element = driver.find_element :name => “j_password”
element.send_keys “#####”
driver.find_element(:name, “login”).submit #<== from here the code went
to forever loading and after that thrown error.Not reaching to the below
statement. tried also - “driver.manage.timeouts.implicit_wait = 10”. But
no result.

or here should I need to put this -

“driver.manage.timeouts.page_load = 180”?######

Please confirm me!

driver.find_element(:link_text, “employelink”).click

Love U Ruby wrote in post #1095127:

Getting the below error:

C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in rescue in rbuf_fill': Timeout: :Error (Timeout::Error) from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:inrbuf_fill’
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in
readuntil' from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:inreadline’
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in
`read_status_line’

Is there anyway to handle these exception,try to make alive the driver
continue with the browser till the page load completed?

Is there any chance to stop loading of a page in a browser? Just we do
manually on a browser by clicking on a cross sign.

Thanks

How long does the page take to load when you do this manually? Adjust
your timeout accordingly.

You can add your page load timeout setting anywhere after creating the
driver object.