How to install Sikuli in IntelliJ Idea? - selenium

I want to automate a Windows app which will also become a mobile app. I am thinking of creating a test automation framework from scratch using IntelliJ.
Since the older tests are already written in Sikuli, I would like to keep them too. What are the steps for setting up Selenium and Sikuli in IntelliJ?

I would recomend you use Maven. In this case you just need to add next dependency to POM.xml
<!-- https://mvnrepository.com/artifact/com.sikulix/sikulixapi -->
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.999</version>
</dependency>

Related

SpringBoot Selenium Automation

I have created Spring Boot web app and its working fine. Now I am writing selenium automation for my web app. I have written some test case. But when I am executing the test cases by using mvn test its giving following exception.
java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
Can someone tell me why this is error?
You might missing the jar
make sure you have httpclient 4.5.2 or higher in your class path.
refresh eclipse
Close Eclipse.
clean .m2/repository folder
Open Eclipse and Alt+F5 on project;
check option Force Update of Snapshots
Use
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.+</version>
</dependency>
and check

ScalaTest: testing web apps with multiple browsers

I am trying to have the same integration test for a web app with multiple browsers (Chrome, Firefox, InternetExplorer, etc. one after the other).
ScalaTest plus Play has these traits AllBrowsersPerTest and AllBrowsersPerSuite. Did anyone wrote something similar but not tied to a web framework? (The web app I am testing is based on Wicket, not Play.)
I was able to solve my problem using PageObject.
PageObject uses all available browsers (i.e. those with a configured WebDriver) by default (in my case Firefox, Chrome and Internet Explorer).
These are my dependencies:
<dependency>
<groupId>org.pageobject</groupId>
<artifactId>scalatest_${scalaBinaryVersion}</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
I found the code of PageObjectTour helpful to get started.
Note: PageObject 0.1.0 uses its own version of ScalaTest 3.0.0 because of a bug not yet fixed in the ScalaTest trunk. So I had to remove my own dependencies to org.scalatest:scalatest.

intellij JavaDoc browser plugin can't find javax

I'm on Arch linux x64 machine , I installed intellij idea but whenever I open a project a startupabortedexception occurs with the JavaDoc browser plugin.
I looked into my idea.log and figured out that it can't find javax.servlet.Servlet, I disabled the plugin in order to open a java project and indeed when I type import javax; it says it can't find javax.
I have java-openjfx installed and still intellij can't find it, what to do in this case ? .
Environment information
jdk:openjdk 1.8.0_60 64 bit.
intellij version: 14.1.5 community edition.
Goal
My goal is to get the JavaDoc browser plugin to work not to program in javax.servlet, I don't intend to do any web development with java right now.
If you don't have Maven project, you can just add the jar to the project. The one you are missing can be downloaded from:
http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/3.1.0
(just click "Download (JAR)" button)
The class javax.servlet.Servlet is not part of the standard JDK, it is part of the JEE, so you have to add servlet-api.jar to your classpath.
If your project is a Maven project you add the dependency like this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
And you probably want to add
<scope>provided</scope>
as this dependency is most likely present in your application server.

How to add Java EE Servlet API library on your compile classpath in IntelliJ

I am new to IntelliJ and I have been working on a few small projects to familiarize myself with IDE and how to develop Java web projects with it.
I recently picked up Professional Java for Web Applications to practise my web development skills and I wanted to try it because it focuses on IntelliJ rather than Eclipse.
My main issues are from not knowing my way around the IDE at all. I have come across a problem that I have been unable to figure out how to do correctly.
How do you add Java EE Servlet API library on your compile classpath ?
Where is the compile classpath located in IntelliJ ?
Any help is appreciated!
This depends on how you are managing dependencies in your project.
If you are using Maven simply add it as a dependency in your pom.xml. When IDEA sees a maven based project it will over for you to Import Changes and/or Enable Auto Import. A common JavaEE 7 maven dependency would look like this in your pom.xml:
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
If you are only using an IDEA project to manage things (vs. maven, gradle etc.) then you can go into the project structure dialog, click on modules and select the module containing your web tier code. Then click on the dependencies tab. Then click on plus button (+) and add a JAR, then navigate to the JAR containing the servelet APIs that is bundled with your application server and select that.
There are another half dozen ways to set this up and exactly which one you choose depends on a lot of factors like how you want to manage provided dependencies in your project etc. Either of these methods should get you on your way though.

Using different eclipselink than bundled in glassfish-embedded-web

I use glassfish-embedded-web for integration tests inside a maven project:
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-web</artifactId>
<version>3.2-b06</version>
<scope>test</scope>
</dependency>
glassfish-embedded-web comes with Eclipselink 2.2.0, but the project requires features of 2.4. For regular deployment, this is solved by adding je required jars to glassfish's modules directory and this dependency:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
I tried also compile scope, still the embedded EL 2.2.0 is used. Adding a test scope dependency on EL 2.4.1 doesn't help. Is there any way to solve this?
Did you try to specify the maven scope test? Otherwise it will not be available while testing! To only provide this version for testing you could use maven profiles.
I see two possible solutions to this problem: either you build your own glassfish-embedded or you just use a brute force approach and modify the jar.
On the 1st approach:
After spending some time building GF I figured that even with my dilettante shell scripting skills its easier to just use the second approach instead of figuring GF code. However, if you're up for this one I'd suggest to start at oracle wiki.
On the 2nd approach: As I've mentioned above, automating this task is the best approach in my opinion (at least if you're dealing with numerous libs and continuous changes), so I wrote this script with all the necessary instructions on how to use it. After you get the new jar just install it in your local repo. I'm using Nexus so for me it was a matter of couple buttons getting pressed.
P.S.: Any comments/advices/improvements on the script are welcome.