1 liked this
Does anyone have any examples of Twist integrating directly with Maven? ie. without going via ANT? I am struggling to follow the examples in a clear and concise way. I am unsure if the maven antrun plugin is somewhere in the installation or actually something I need to download. (Downloading is tricky we are fairly locked down here).
What would be great is if someone could put up a hello world example of using maven with a twist project, maybe with selenium, maybe it loads google, with a twist test, testing that it can find google, and then the example maven file structure. If it can't work without ant, then maybe the ant buildfile too.
I am running Twist 2.3.1 on RHEL and using Spring. I am using image based testing with Sikuli, as mentioned in another Twist post. In the applicationContext-scenario.xml I have a map of lists that one of my test scenarios needs. You can see the spring code in the code snippet area. I am using the @Resource(name="mapOfAttributes) to inject the map. I can't use Autowired b/c it supposedly doesn't work with maps, I tried it. The java code is also in code snippets area. This scenario is a table driven scenario. Before my scenario executes, I have a context that launches the browser and does some other cleaning up stuff before running the test. I have some Guava code that checks the map is not null and it always fails. What do I need to do to have this value injected?
1 liked this
What is Sikuli?
Sikuli is a visual technology to automate and test graphical user interfaces (GUI) using screenshots. You may read more about it here: http://sikuli.org
Installing Sikuli:
You can get the latest version from here: http://sikuli.org/download.shtml
Note: If you are using linux you will need to have wmctrl, and OpenCV 2.1 installed.
Using Sikuli with Twist:
There are two distinct parts to using Sikuli with Twist. The first part involves wiring Twist up to use the Sikuli jars. The second involves getting the screenshots you will require to automate your application.
To wire Twist up with Sikuli:
The Sikuli IDE you downloaded has a jar file called sikuli-script.jar. You can find this jar file under the lib directory of your Sikuli installation. You will need to copy this jar file into a directory called libs(create "libs" if it is not already present) in the Twist project where you intend to use Sikuli.
Now you can let the Twist project know that you have inserted a new library. You may do this by right clicking on the project, selecting "Properties>Java Build Path" and selecting the "Libraries" tab. Click on "Add JARs" and select the sikuli-script.jar by navigating to the libs folder under your twist project. Click on Ok.
The final part of wiring up Sikuli involves the creation of beans in your applicationContext-suite.xml file. Doing this will let Twist know how to instantiate your driver and make it available to your test code. Add the following right at the end of the applicationContext-suite.xml file, just before where it says </beans>:
<bean id="sikuli" class="org.sikuli.script.Screen"/>
This bean will make the "Screen" object available to your test code. You will use the Screen object to interact with your applications.
Now that Sikuli is wired into Twist you will be able to use it in any fixture. To test it, open a scenario you have written, or write a new scenario with a single workflow step under a fixture. Implement the fixture and navigate to the code. Create a constructor for your fixture and introduce the Screen object as a parameter in your constructor. The best way to do this is to type Scree and then press Ctrl-Space to pick from a list of suggestions(make sure you pick the option that has org.sikuli.script in it). Your constructor will then look something like:
public FixtureName(..., Screen screen) {....
If you just typed "Screen screen" instead of using suggestions, you will see Screen underlined in red. This is just letting you know that you haven't included an import statement to import Screen. This is easily remedied by typing the following at the top of your java file:
import org.sikuli.script.Screen;
Automating with Sikuli:
Sikuli works by using screenshots of specific parts of your application(buttons/textboxes etc) and performing actions on them. It is therefore imperative to have those screenshots in your Twist project. You may use the Sikuli IDE to capture the relevant screenshots for the application you are testing and then copy those over to your Twist project under a folder called "images" or something appropriate.
Once these screenshots are in place, the rest of it involves making appropriate calls to Sikuli.
For example if you have captured the Windows "Start" button as one of your screenshots, you can get Twist to click it by using:
screen.click("images/start.png");
inside one of your workflow steps.
Sikuli works very well where your application has common visual components across multiple screens but does not have a driver to easily access these controls. Flash based applications are a good class of applications that can be tested with Sikuli.
Happy testing.
When I launch firefox from the command line, I am able to view PDF's in my browser. I am testing my GUI with Twist and using the sikuli driver. Before I run the test I close the browser. The line of code that opens the browser says: App.open(PDF_ENABLED_BROWSER + " -new-window " + URL When I try to open a PDF I get the following error, Could not launch Adobe Reader 9.5.1. Please make sure it exists in PATH variable in the environment. If the problem persists, please reinstall the application. I am running on RHEL and using Firefox 3.6.23, not by choice. Any help is greatly appreciated.
I have a case where in the Login class I want to know which type of browser I am using. What is the mobile server address. What is the version of browser and other settings defined in twist.Properties
I am using the default system web browser instantiated by the twist. Twist version is 2.4.0.12621
Please let me know how to implement this or procedure for the same.
Thanks,
Sarita.
Hi,
We are fairly newcomers to twist and are currently looking to resolve a few issues.
Firstly when we used Selenium 0.92 we just needed to have the avoid proxy settings in the properties file to enable us to use IE. Which worked ok.
Now we are using Selenium 2.0 as its shipped with the updated version of twist (currently 2.4) and although I can get firefox to work, I cannot get IE to work, even if I put in the cgi script location under the "browser script location area" http://autoproxy.intranet.whatever.com/cgi-bin/pac.fcgi.
Can anyone shed any light on this as I cannot be the first person to have had this issue ? I could try using the 0.92 version again and use the -proxyInjectionMode -avoidProxy commands but that seems like a step backwards to me.
Cheers Rob.
ps. error is:
19-Mar-2012 11:20:44 org.openqa.selenium.remote.RemoteWebDriver execute
INFO: Executing: [null, newSession {"desiredCapabilities":"Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}]"}]
Twist 2.3 is out fresh with loads of new features, enhancements. The following is a peak onto “Twist Project Properties” UI.
Until Twist 2.2, for changing any property of a Twist Project, you had to open the “twist.properties” file and manually edit the properties. While we had good documentation, there always used to be human error factors, little pesky issues of some property not being properly edited, a comma or slash (\) missing out etc etc. Or for that matter, if you would want to run your test against another browser, you would have to enter the “code” manually editing the properties file.
With Twist 2.3, you no longer need to be bothered about such things. Here’s a screenshot of a Twist Project’s properties for chosen driver as “Selenium2”.

The first tab “General” shows you the twist specific properties.

The properties UI is dynamic and depends on primarily the driver defined for the Twist Project and secondarily on the chosen agent (Browser). For example, following is the properties UI for project with Sahi as Driver.

You can just change the “Browser” from the drop down, and run your scenarios on chosen browser.
The “User” tab shows you any custom property you may have added. This means that any property not recognized by Twist and the chosen driver will appear in the “User” tab.

The properties UI makes test configuration for multiple environments significantly easier.
To test on different browsers, just go to project properties and select “Twist Properties” on the left pane, and change the “Browser” property, and execute a scenario, and the scenario will run on the chosen browser.
Not just that, the editor GUI can edit any properties file under a twist project. So, if you want to manage configuration for multiple environments, just create multiple “<env>.twist.properties” file and edit with the properties editor.
I'm evaluating Twist as a possible automated testing tool for testing iPhone/iPad apps. Does it support automated testing of HTML within a UIWebView on these devices (or simulators)? In other words can I exercise the inner HTML (click buttons, links, etc.) via Twist "scripts"?
Thanks!
Brian
The idea of this post is to demonstrate WebServices testing from Twist. While some of our customers have already been using Twist for services testing, this post will hopefully show you easy enough steps to test your WebServices while still leveraging the authoring, maintenance aspects of Twist. In this example, we will test a simple temperature converter service exposed at http://www.w3schools.com/webservices/tempconvert.asmx, which provides simple celsius to fahrenheit degrees conversion.
Pre-requisite:
1. Creating the project
2. Generating the building stubs, skeletons, and data types from WSDL.
What we want is a simple and usable enough java interface for accessing the remote WebService. something like:
converterService.celsiusToFahrenheit("32")
A fair amount of boilerplate code must be written to access the Service. Thankfully, we can automate all that code generation. We will generate the bindings necessary for client side testing of the service using wsdl2java utility shipped with CXF. To do this:
If you look within the package contents classes, you will find an interface annotated with @WebService (org.tempuri.TempConvertSoap). This interface has 2 basic methods that represent the operations supported by the WebService. This is the remote interface we are going to use in our Test fixtures.
Another class (org.tempuri.TempConvert) will be generated annotated with @WebServiceClient. This is the class that will return the remote interface. Methods annotated with @WebEndpoint will return you a remote interface. (in this case, we have used TempConvert.getTempConvertSoap() method)
NOTE: If you would want to customize the JAX-WS implementations created by wsdl2java, it can be done by using a customization binding file. Please refer here for more information.
3. Adding CXF Library references to your project
4. Creating the remote interface instance
<bean id="tempConvertorFactory" class="org.example.ConverterServiceFactory"
init-method="start" destroy-method="stop" lazy-init="true">
<property name="wsdlLocation" value="classpath:tempconvert.asmx.wsdl"/>
</bean>
<bean id="converterService" factory-bean="tempConvertorFactory" factory-method="getConverterServicePort"
lazy-init="true" scope="singleton">
</bean>
5. Creating a scenario and generating test fixture
Temperature Converter:
- verify that "100" degrees in centigrade is same as "212" degrees fahrenheit
6. Injecting the service interface to the fixture
public class TemperatureConverter {
@Autowired
private TempConvertSoap converterService;
....
}
7. Calling a remote service operation.
public void verifyThatDegreesInCentigradeIsSameAsDegreesFahrenheit(Double celsius, Double fahrenheit) throws Exception {
assertEquals(fahrenheit, Double.valueOf(converterService.celsiusToFahrenheit(celsius.toString())));
}
8. Execute the scenario
Additional support from Eclipse WTP
To seasoned Twisters this may be obvious, but here's one example how to use a simple java class as a bean to set/get values across scenarios.
For example, say you are testing a web application and do some search, store values of search, and assert/do-something later on in another fixture/step.
1. Create a Java class. For example, below is a simple class which has a key-value map, and provides simple apis for storing/retrieving values. In this example, the class is created in package "com.orgname.test" under the Twist test project's "src" directory.
package com.orgname.test;
import java.util.HashMap;
import java.util.Map;
public class AppDataPlaceHolder {
private Map<String, Object> values = new HashMap<String, Object>();
public void setValue(String key, Object value) {
values.put(key, value);
}
public Object getValue(String key) {
return values.get(key);
}
}
2. Now define this class as a bean in "applicationContext-suite.xml" for your Twist test project. This will cause the bean to be instantiated when any test execution is requested for.
<bean id="appData" class="com.orgname.test.AppDataPlaceHolder"/>
3. In a test fixture, where you may want to store some application state across scenarios/steps, you may inject the above "ApplicationValues" object through the constructor. For example, if you have a fixture called "Search Amazon", then modify the constructor like below. Note, the example shows for a Twist Project with WebDriver as selected driver, but the pattern is same for any driver that you might have chosen.
.....
.....
import com.orgname.test.AppDataPlaceHolder;
public class SearchAmazon {
...
private AppDataPlaceHolder appData;
public SearchAmazon(WebDriver browser, AppDataPlaceHolder appData) {
this.browser = browser;
this.appData = appData;
}
.....
}
4. Now from any step implemented in the "Search Amazon" fixture you may store values onto the "AppDataPlaceHolder". For example, if you want to store the best-buy book for the author, you may do something as below
public class SearchAmazon {
.....
...
private AppDataPlaceHolder appData;
public SearchAmazon(WebDriver browser, AppDataPlaceHolder appData) {
this.browser = browser;
this.appData = appData;
}
.....
public void searchForAuthor(String authorName) {
//code to search for author
appData.setValue(authorName, browser.findElement(By.className("best_buy")).getText());
}
}
5. Now from another fixture you can access the previously stored values. (You just have to inject the "AppDataPlaceHolder" through the constructor like above):
public void verifyAuthorBestBuy(String authorName, String bookName) {
Object bestBuy = appData.getValue(authorName);
.....
}