how to handle delays when web pages get long to load? - watin

I am doing some unit testing using watin. but the problem is when a web page gets too long to load, the test automation fails because the required element is still not available but the control action is already executed in watin.

Just set Settings.WaitUntilExistsTimeOut to wait as many seconds as you need.

Related

End to end page rendering time for performance test jmeter

My requirement is Overall response time, end to end time including rendering of page in browser should be 3sec . I have to execute Load test for 200 users. So in this case, the response time displayed in JMeter wont be end to end response time right. So during Load test execution , if i execute selenium functional automation scrip during 200 user load test ,whatever time we capture in selenium will that be end to end response time including rendering time? Or JMeter load test response time will be end to end response time?
Can someone please guide me if this is the right way?
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So JMeter's response time is the time to get the last byte of the response from the server, it doesn't "render" the page at all so if you're looking for that metric as well - stick to Selenium tests (you might want to use i.e. Navigation Timing API to know what exact rendering time is)
JMeter can be integrated with Selenium via WebDriver Sampler

Wait until option JMeter

I wanted to know if JMeter has a option where you wait until some element disappears.
Example a loading bar only once that has completed or no longer visible then to carry on. (Also being able to monitor the length of time taken)
I have through about writing it as a webdriver test and then running it as a Junit test in JMeter but wanted to know if there is a simpler solution.
Any ideas welcome :)
First of all you need to realize that JMeter is not a browser
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So JMeter doesn't execute any client-side JavaScript, the only way of implementing "wait until" option is using While Controller in order to re-execute the same request again and again until response data will contain (or stop containing) the element you're looking for.
If you need to evaluate client-side JavaScript the only option would be going for Selenium. I would recommend using WebDriver Sampler instead of going for JUnit as this way you won't have to recompile your script for any change, it will be inlined into .jmx
You can use Transaction Controller to monitor the time taken by the whole process and to wait for a change , have a look at this:
http://www.sourcepole.ch/2011/1/4/waiting-for-a-page-change-in-jmeter

Cancel page load in Capybara

I am testing a page which contains a pesky iframe which takes a long time to load; however, I'm not testing the iframe itself. If possible, I'd like to be able to run my tests without having to wait for this iframe each time.
One of the following potential solutions should do the trick, but I'm having difficulty either finding documentation or getting any of them to work:
a) Cancel the page load shortly after the request is placed.
b) Simulate an Escape press while the page is loading using send_keys method.
c) Use javascript - page.execute_script("return window.stop();") while the page is loading.
d) Cancel loading of a specific element
How would one send a cancellation request to a loading page or element using Capybara?
We were having problems with outstanding network requests (both Ajax and assets) at the end of our integration tests, when all the assertions had been met and the test was over and getting torn down.
So we added execute_script("window.stop();") to our integration_test_helper.rb file, in the teardown block, and it worked very well.
So I'd suggest adding an assertion that can be met before your iframe is fully loaded, and running window.stop() in the teardown of the test.
Altnerative here, you could use puffing-billy gem to stub that iframe request.

is there are way to ignore page load when running seleniume cucumber

Hi is there any way to ignore the page load when running selenium cucumber, because it always fail my test and i just want to check if that content is present or not.
please don't say add sleep.
the issue im having is that the content is present but its always waiting the page to be fully loaded and sometimes it got stock trying to get some api call to a 3rd party company.
Here are some approaches you could try
Change your driver and us webkit. Setup webkit to not load external links. See http://robots.thoughtbot.com/speed-up-javascript-capybara-specs-by-blacklisting-urls
Ensure you understand and us the has_no methods if you are testing that something is not present e.g. use
expect(page).to have_no_css '.test' # fast
rather than
expect(page).to !have_css('.test') # slow will always wait until timeout
Change the default timeout to something shorter (perhaps only for this scenario, using a tag)

How can I set up my vbs program to know when Firefox has loaded a web page completely?

I am using Firefox to load programmatically a webpage (I use a vbs file).
Dim objShell
Set objShell=CreateObject("WScript.Shell")
objShell.Run "firefox.exe http://www.google.com/"
Then, I have set a time out to allow browser to load completely the web page before my program to continue with the next steps (a web page is expected to load in maximum 5 seconds):
WScript.Sleep 5000
However, there are webpages that are loaded in 20-30 seconds.
In order to define an appropriate time for each user to expect the page to load, I need to know how can my program know when Firefox has loaded a web page completely.
Constraints
Javscript is disabled for users (company policy)
Of course, to cover all cases I could setup a 50 seconds time within the program, but I am afraid the user will become bored for pages that are loaded in 5 seconds and then the program does nothing for the next 45 seconds.
I don't believe there is a reasonable way for you to know when Firefox completed it's loading task from a visual basic script...or from almost any other execution environment. It's a separate process and the only way you could accomplish your goal is if the browser provided an API to query it's status, receive events etc.
If it's really important, you might try to write a browser extension which might be able to inform you when the page has been loaded.

Resources