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

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

Related

When I must log out user if I use Specflow and Selenium (BDD)

I have started to use Specflow, Selenium and PageObject pattern for testing. I would like to make scenarios independent of each other, but when I start running my test features, I see that my user is not anonymous after the first scenario.
When should I log out the test user?
Before each scenario?
After each scenario?
Can specflow and selenium drop state after each scenario?
Must I call page.Logout() every time?
I would say that you should log out, when it's relevant to the test case. Say you log in to SO and test posting a new question, then write an answer and add two comments to each. Logging in and out between each step would be a big hassle and no user would do that in the real world. Thus just log in at the start of the test scenario and log out when you're finished with it.
Another example would be doing each of the above steps as different users, then it would be a necessity to log in/log out at every step.
This applies in the bigger picture as well, if you have multiple scenarios that require a logged in user, but don't depend on any of that user's information, may as well just log in once before running all of them and then log out.
Specflow and Selenium don't hold the state, it's the system you're testing that does it. For instance if your session is stored in cookies, you could clear said cookies and that would in effect log you out. But this is not testing the system as the end user is meant to use it, so it's just cutting corners and testing different area of system (authorization of unauthenticated users) and thus doesn't really correlate very well to the real world case. Just use the log out button/link on the page, since you're writing browser based tests.
I think you should make your test feature wise or module wise.
if you consider all the processes in a feature and according to the flow, you will only need to logout in the end.
If you make module wise, after a process you can logout each time and login again at the new module.

How to simulate 20 users click a button at the same time in Web GUI Test Automation

Now I hava a requirement about Web GUI TA
I want to simulate some users(20-30) click a button at the same time and evaluate the performance of Web GUI at that time.
I use RobotFrameWork + Selenium library to do the Web Gui TA before, but as far as I know. selenium library only can handle one broswer at one time, so i dont know how to do now.
Can you give me some advice? need use another library or framework?
Like mentioned by other, what you want to do in this case is not UI testing but rather stress/load testing. You should be able to try easily Gatling. First you record the http request associated with the click on your button. Then, you write a simple scenario that launches this request 20 times at once. Something like:
setUp(scn.inject(atOnce(20 users)))
.protocols(httpConf)
Selenium has a "grid" option you can use to configure many instances running many browsers.
http://www.seleniumhq.org/projects/grid/
http://www.seleniumhq.org/docs/07_selenium_grid.jsp
Grid allows you to :
scale by distributing tests on several machines ( parallel execution )
manage multiple environments from a central point, making it easy to
run the tests against a vast combination of browsers / OS. minimize
the maintenance time for the grid by allowing you to implement custom
hooks to leverage virtual infrastructure for instance.
In short, you create a "hub" that manages things, then each "node" can perform tests as required by the hub.
Consider, however, this may not be the best route to go down. Something like multi-mechanize might be more useful: http://testutils.org/multi-mechanize/
That will allow you to have many users "clicking" the button, but not via a browser but via direct HTTP calls. That might be more suitable for multi user simultaneous "headless" load testing, which is what I think you are attempting to do.
I'm slightly confused at this question:
Are you wanting to test the GUI? If it's something like "This button makes a dropdown menu appear", then it doesn't matter how many users do it at the same time, it'll either always work, or never work.
Are you wanting to test the server under load? If so, then Selenium will work, but there are better tools. I have used JMeter with success, but there is a really good listing of all of them here: http://performance-testing.org/
Finally, are you wanting to press 20 different buttons on the same page on the same browser at the same time? If so, this isn't possible with selenium, and it isn't a standard use case either.

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.

Taking screenshots of a page while its loading using Selenium WebDrivers

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.