Taking screenshots of a page while its loading using Selenium WebDrivers - selenium

I have started using Selenium WebDrivers to automate some performance testing. I found out that we could take screenshots of a page after the page has completed loading using WebDrivers: http://seleniumhq.org/docs/04_webdriver_advanced.html#taking-a-screenshot. However, I want to be able to take screenshots while the page is loading to analyze its loading time and pattern, much like what webpagetest does (http://www.webpagetest.org/). Is there an API that I could use to accomplish this task using WebDrivers?
I am using the FirefoxWebDriver and the Java client for the same. I appreciate help or tips.
Thanks!

Since, I found out that the RemoteWebDriver's get calls are blocking and even the getScreenshot calls are blocking, I decided to run java.awt.Robot in a separate thread and capture screenshots while the WebDriver loads the page.
The only caveat is that the browser instance opened up by the WebDriver has to be in the front of the screen to take snapshots correctly. I am exploring if Robot can take snapshots on an Xvfb display, which would be just awesome and would work for my purposes.

Related

Can I bypass waiting for the page to load in TestCafe?

Is there a way to bypass the page load wait? The product I am testing is in an iframe, independent of the page that it loads on. However, the host page takes forever to load, unnecessarily increasing my test times. So I am looking for a way to bypass the page load and instead wait on the iframe to finish loading. ideas?
TestCafe is an end to end testing tool. That means the original page load time is a part of that. I don't think it would be a realistic test if you excluded that part.
That being said, I understand the frustration of waiting in the given scenario. Maybe TestCafe Live mode could help you, at least during the development of tests.
For, example if you wish to run screenshot.js you will need to add --live switch:
testcafe chrome screenshot.js --live

Python Scrapy Splash doesn't render website, stuck at loading screen

I would like to render the following website with Scrapy Splash.
https://m.mobilebet.com/en/sports/football/england-premier-league/
Unfortunately, Splash always gets stuck at the loading screen:
I have already tried using a long waiting time (up to 60 seconds) with no results. My Splash version is 3.3.1 and obey robots.txt has been set to false.
Thanks!
There's not quite enough info to answer, but I've got a good guess.
You see, the major difference between Splash and your browser is the user agent string. You have one that looks like a person. Splash generally doesn't.
This kind of infinite loading is a method used by sites to mitigate repetitive load. Often when you're developing locally without a proxy you'll trip these issues. They are quite maddening to develop against because they're inconsistent.
Your requests are just getting dropped, you'll probably see a 403 after 5-10 minutes.
I think it's likely you can solve this issue with the method mentioned in this answer: Scrapy+Splash return 403 for any site.
I don't think it'll be possible - this website needs JS to be rendered. So you'll need to use something like Selenium to scrape information from it.
Also, perhaps what you are looking for is an API for that information - since scraping it from a website can be very inefficient. Try googling "sports REST API" - look for one with Python SDK.
Ok, so Splash is supposed to render the JS for you it seems. But I wouldn't rely on it too much - those websites constantly change and they are developed against latest browsers, your best bet is to use Selenium with Chromium driver (though using API is much more preferable).

Launching selemium scripts from browser for screen capture

I am looking for creating a functional training package for a web based product (more like a screen capture).
However, the requirement is not just to have screen capture, but to have a test mode for the training where we can prompt the user to click on the screen and check if they have done proper flow.
for e.g. A banker will first go through the screen capture to see "how to open an account" in the core banking application . Later user will be presented with a test where user has to click through all the controls and flow.
I have seen selenium being used for authoring good UI automation test cases, so I wanted to explore the possibility of using selenium for creating these training modules
These training modules needs to be launched from intranet application. Is it possible to launch selenium authored UI automation test cases from the browser? I want to stay away from writing any extensions or plugins.
I haven't used selenium and I might be completely off tangent here, so any other suggestion to achieve this using open source tools are welcome.
Without writing any scripts, you may consider downloading Selenium IDE. It has a recording and replay function that may meet your need.
For a fast tutorial, please follow this link.
https://www.youtube.com/watch?v=gsHyDIyA3dg
Hope it helps.

How to set manually opened browser as Selenium webDriver

I am working on automating a web application.
I have many pages like login page etc. and I have many tabs. Each tab will open different page, for example, if I want to open page3, I have to go through page1 first then page2.
Here my problem is If I want to test some functionality on page3, then I have to go through all pages. It is taking so much time to test single functionality I need to spend so much time.
Is there any way I can set already opened browser as Selenium WebDriver?
Unfortunately, no.
This is the most starred feature request on Selenium as of now (February 2013, current Selenium 2.30.0). It's also one of the oldest.
http://code.google.com/p/selenium/issues/detail?id=18
There has been some work on Firefox for this, but it's undocumented, very experimental and no changes have been seen on it for quite a while. For more information, look at the linked feature request.
Front-end automation is hard, Selenium can only do what a normal user could do. The best you can do is to run the tests in parallel on many remote machines.
No... It is not possible....
In order to reduce the manual execution, we are moving towards automation.
Inbetween you cannot automate.

Playframework selenium autotest debugging

I am developing a play 1 application and testing it with the selenium. In several cases, play auto-test fails when normal testing within a browser (play test) succeeds. This can be due to different behaviour of js/ajax, or development mistakes on my side.
Is there a way to get some more feedback regarding what's going on in the headless browser? For example, assertTitle does give some feedback, as in the test-results HTML the title found is displayed.
Are there ways to get a the whole response at a given point, or any other usable feedback to debug the application and the test cases?
It would be better if you could give some more details about what all things are failing in your tests, give some code examples which u are writing.
Even i had faced lot of issues in running selenium tests in play auto-test, u can refer this link for our issuesPlay Auto-tests issues
The best way to debug the selenium tests is to use echo and see what are the results it is returning.