How to add a button in FitNesse Test case? - java

The scenario is as follow:
I want to pause the test when it encounters the Button in the Wiki page Test Scenario. It should wait until the user presses the Button and once the button is pressed the test should continue.

As the automated tests are designed to run in a full set without any monitoring or midway user interaction, this is not a standard feature. Feel free to edit the source where needed and recompile.

Since you tagged this question with Selenium-fitnesse-bridge, my assumption is that you are testing the browser user interface of an application via Selenium webDriver, but instead of driving the tests from xUnit you are driving from fitnesse.
First, this isn't really the sweet spot of fitnesse - it's main purpose is to test business logic by interacting with System Under Test as opposed to running end-end tests by driving a browser - however, that soap box aside, you are creating fixtures for fitnesse to interact with - and those fixtures currently contain webdriver code. So you can put the pause inside your fixture class. I'd need to see your test table and whether you are using Slim or not to get an idea of where the logical place in your fixture code to place the wait would be.
The only problem with that solution is if you want to specify on the fixture page that there should be a wait at a certain point - you don't just want it behind the scenes in the webdriver code. In that case, you could probably use a ScriptTable style of fixture (http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ScriptTable) and have a command in the script that maps to a method that waits for the specified amount of time or for a specified element to be visible.

Related

Selenium Serenity screen shots and movie delays and hangs the execution

We have a serenity framework, where by the screenshot and movie on failures are recording during the execution and is part of it and happens sequentially
i.e
Test Case Step1 - Pass
Test Case Step2 - Fail
Movie and Screenshot of failure for Step2
Test Case Step3 - Pass
The movie and the screenshot are uploaded to the FTP server which can cause slowness and sometimes it hangs if the network is slow
My question is:
Where is the best place to save these screenshot and movie? Will Netapp or box.com solve this? I believe not as they too depend on the network speed
OR
Can we use threads i.e the execution continues and we create another thread which handles screenshot creation or movie and does the upload, without impacting the current execution. But, i am not sure if serentity supports this
OR
Save the files in the local project directory and then upload them after the execution?
The execution results are very important and they need to be backed up
Serenity BDD does not record movies, only screenshots; these take very little time if you configure them to only be take on failures, and these are taken and processed in a separate background thread (so saving them doesn't slow down the tests, though the WebDriver calls to retrieve the screenshot data will slow down the tests when screenshots are taken for every action). It doesn't currently support uploading the files anywhere though.
I presume the movies you refer to are done within your own code, so Serenity would have no control over these.
Screenshots are automatically recorded alongside the other test outcomes. The simplest approach would be to upload/sync them after the build has completed, or to simply store them on your CI server (which is what most shops seem to do).

UI automation code for Optimizely test

I am new to Optimizely A/B testing. My question is, I have automation code of test cases for UI and if someone changes the UI using Optimizely, How can I make sure my automation code of test cases doesn't break because of those new changes from Optimizely ??
You basically can't; Optimizely is code injection. It's the responsibility of whoever's monkey-patching the UI not to break it.
If you've got something like Selenium or Ghost Inspector checking things on an actual running website using URL's as a target, you can just opt-out of Optimizely tests for the purposes of verifying your UI. To do that add optimizely_disable=true or optimizely_opt_out=true as a query parameter to the URL's you're checking. i.e. http://youramazingsite.com?optimizely_disable=true

Error: When i minimize Internet Explorer which is running the automated WebDriver Code

I have written the Selenium webdriver java code to automate the test and its working fine. But I have lot of data input to test my web and it takes time. So when i minimize the IE to do some other task while it is running the automation, it is throwing error:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed
Selenium WebDriver is trying to simulate "real" users interaction with the webpage. If a person can't click on a button not currently displayed, neither can Selenium.
ElementNotVisibleException occurs when the element you want to interact with is not displayed. When you minimize the browser some of the elements are no longer visible, even though they where in maximized window.
You can add scroll using moveToElement() from Actions class every time you want to perform any action (I don't recommend it, you increase significantly the chance for errors), or find another hardware solution, like plugging in another screen, run the test on another computer etc.
According to my experience, the Internet Explorer WebDriver is very oversensitive when it comes to disturbances from a real user while running test cases. It's better to not touch anything at all. ;-)
Try Chrome! This is much more robust and also faster.
Selenium script runs as a simulator. You cannot do another work when script is running. Chrome is fast but while running script in chrome you can not do other task like any other browser. If you minimize window, you will get exception "ElementNotVisible".

Selenium time execution of test

My Selenium test clicks on some elements of a page and executes javascript. How can I time this entire workflow? I am not testing the page load speed but rather how fast Selenium finishes execution of all the tasks I give it. I am using Java.
The easiest (and most thorough) out of the box solution is to use Selenide, which has a really nice (undocumented) feature that is able to give timings of page loads and components in a page. But, you could add your own timer events to the Configuration methods of a JUnit or TestNG test. Take this page as an example: How can we get exact time to load a page using Selenium WebDriver?

Selenium RC and Internet Explorer

I am trying to create a fully-automated test suite for a web application, using Selenium RC and test cases written in Java. However, I have encountered a few problems that I have not been able to solve. Please let me know if you have a suggestion about any of these issues.
Single window mode. I would like to run single window mode because I think it will provide a significant performance improvement, and probably solve problem 2. I am able to run my test cases in single window mode with Firefox and everything works as expected, with much faster execution. However, I have not been able to get my test cases to execute when using single window mode with Internet Explorer; button clicks do not work at all, so the tests fail due to the browser never advancing to the next screen. The exact same test case executes fine in multi-window Internet Explorer. Is there some kind of trick I can use to get this working?
When running in multi-window mode, if there is an error in the test, or if the user exits the Selenium GUI window, the browser never closes. I know that it is possible to get the process id and kill it, but this seems rather dangerous, especially if the user is running multiple instances of the browser. This is part of the reason that I would like to use single window mode, if possible. Is there some other way, possibly by handling the window close event for the Selenium GUI, to solve this?
I am unable to use the waitForPageToLoad command in any of my test scripts because it will never recognize that the page has loaded and resume execution. I think this is because the pages use Javascript, but I am not sure; I don't have too much experience in webpage development. Right now, I am using the wait command and specifying the amount of time to wait. However, this is very unreliable, sometimes if the Internet connection is slow, my tests fail because the wait times are not long enough. Other times the tests are excessively slow, due to long wait times. Any ideas for how to handle this problem?
Thank you! I appreciate any answers or suggestions you can give. Please let me know if you would like some more information.
For multi widow close issue, you need to handle the exceptions. Call the close function in the finally block will resolve the window close issue.
For Page refresh, you need to check that manually and call in correct places. Usually clicking on links will cause page refresh before showing next screen.
Have you tried IE HTA mode? When I used to mess with this stuff it was the only reliable way to run tests on IE.
Not sure
You need to use the wait class. In essence you make an action then poll on an element which isn't present yet but you know will be when its safe to continue with the test. So you only ever wait the minimum time needed.

Categories

Resources