No screenshots are captured by serenity after test run - selenium

I have serenity.properties file with such configurations:
serenity.take.screenshots = BEFORE_AND_AFTER_EACH_STEP
webdriver.driver = "chrome"
Also I have PageObjects, Steps layer and Tests module
My Gradle build file looks like:
group 'com.am'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:1.4.0")
}
}
dependencies {
compile 'net.serenity-bdd:serenity-core:1.4.0'
compile 'net.serenity-bdd:serenity-junit:1.4.0'
compile 'junit:junit:4.12'
compile 'org.assertj:assertj-core:1.7.0'
compile 'org.slf4j:slf4j-simple:1.7.7'
compile group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: '1.4.0'
compile group: 'org.jsoup', name: 'jsoup', version: '1.8.3'
compile 'ru.yandex.qatools.htmlelements:htmlelements-all:1.17'
}
gradle.startParameter.continueOnFailure = true
When I run tests with simple command
gradle clean test aggregate
Report is generated but without any screenshots.
My report looks like:
generated report
Could anybody please give an advice where am I wrong?
I think it's some simple one but I can't understand where...
In all manuals it says that serenity makes screenshots by default but I don't have any.

The issue is solved. Driver should be managed by Serenity but I used to create my own instance of a driver.
Resolution:
1. add Managed tag to tests
#Managed
WebDriver driver;
remove from all places any other driver instances.
check that serenity.properties contains (e.g)
webdriver.driver = chrome
webdriver.chrome.driver = pathtodriver/chromedriver.exe

Related

How to properly configure Kotlin plugin for Gradle?

I'm trying to build a basic Gradle project. My build.gradle file is below. I keep getting the below error. I don't get it because you can find the plugin here... where I think I'm directing to: https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin
Update: same thing happens to the spring-boot plugin if I comment out the Kotlin line. It's not just specific to the Kotlin plugin.
The error:
Error:(21, 0) Plugin [id: 'kotlin', version: '1.1.1'] was not found in any of the following sources:
- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/3.3/userguide/standard_plugins.html for available core plugins)
- Gradle Central Plugin Repository (no 'kotlin' plugin available - see https://plugins.gradle.org for available plugins)
Build.gradle:
buildscript {
ext.kotlin_version = '1.1.1'
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'java'
id 'kotlin' version "1.1.1"
id 'spring-boot'
}
group 'si.dime.kotlin.tutorials.rest'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile("org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE")
}
For non-core Gradle plugins (those that are not from the org.gradle namespace), you have to use a fully qualified id as well as a version number.
The official Kotlin documentation contains the id to use:
plugins {
id "org.jetbrains.kotlin.jvm" version "<version to use>"
}
(You can also find these ids by searching for the plugin on the plugins.gradle.org site.)

IntelliJ Idea 16 CE gradle issues

In my gradle file I am trying to use the following to solve another issue. This is my gradle file:
group 'com.winapp'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'src/main/java/libs', include: ['*.jar'])
compile 'com.intellij:forms_rt:6.0.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
task copyDependenciesToTarget(type: Copy) {
println 'Copying dependencies to target...'
configurations.compile.collect().each { compileDependency ->
copy {
with from (compileDependency.getPath()) {
include '*'
}
into 'target/libs/libs'
}
}
}
build.dependsOn(copyDependenciesToTarget)
jar {
manifest.attributes(
"Main-Class": "Main",
"Class-Path": configurations.compile.collect { 'libs/' + it.getName()}.join(' ')
)
}
The problem are is this:
configurations.compile.collect().each { compileDependency ->
copy {
with from (compileDependency.getPath()) {
include '*'
}
into 'target/libs/libs'
}
}
When I run the application I get this Exception:
org.gradle.api.internal.file.copy.CopySpecWrapper_Decorated cannot be cast to org.gradle.api.internal.file.copy.CopySpecInternal
Main problem is, I have no idea how to fix this error, I simply want my project to create a JAR file that works with JDBC, using this gradle code seems to be a solution for that issue, but now I have run into another problem, yet again.
Please let me know if you require any additional information and thank you in advance. Literally, I cant even. This problem.
EDIT
As stated in the comments. My project runs fine when I run it through the IDE. There is an issue when I create a JAR file using gradle. The bare gradle file that IntelliJ created when I started the gradle project follows (Added the jar config so my Main class would be picked up):
group 'com.winapp'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'src/main/java/libs', include: ['*.jar'])
compile 'com.intellij:forms_rt:6.0.5'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
jar {
manifest.attributes(
"Main-Class": "Main",
"Class-Path": configurations.compile.collect { 'libs/' + it.getName()}.join(' ')
)
}
When I execute my app from terminal after the JAR has been created (keeping in mind there are no issues when hitting run in the IDE) with java -jar myAppName.jar:
java.lang.ClassNotFoundException: org.sqlite.JDBC
NOTE: Usually I get a full stack running a java app, but in this case the above is the only output.
I am using this JAR for my sqlite needs:
sqlite-jdbc-3.15.1
As a test I commented out the Sqlite usage in my application and the JAR file worked fine. My GUI was displayed and everything went as expected (all things considered). The JAR stops working when I add the sqlite JAR file usage (code). Added it the same as my other libs (like retrofit), so this seems to be quite a strange issue.
Please let me know if I have explained the issue correctly?

How to debug xtend code in IntelliJ + Gradle?

I have just started to learn Xtend (http://xtend-lang.org/) and try to write a small app in IntelliJ 2016 based on a Gradle project using the Xtext/Xtend 2.10.0 plugins from the standard repository. The problem is that I cannot debug my Xtend code. Breakpoints are all ignored although debugging of Java code works. Debugging Xtend code only works if I use the IntelliJ wizard and create a standard IntelliJ project without using Gradle. I don't know how to fix this? Do I miss something? Does debugging works different in a Gradle project?
Here my Gradle file:
group 'GradleXtend'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'org.xtext.xtend'
sourceCompatibility = 1.5
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile 'org.eclipse.xtend:org.eclipse.xtend.lib:2.10.0'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.xtext:xtext-gradle-plugin:1.0.12'
}
}
xtend {
debugger {
//how to install debug info into generated Java code
//SMAP adds Xtend debug info on top of Java
//PRIMARY makes Xtend the only debug info (throws away Java line numbers)
//default is SMAP for Java projects and PRIMARY for Android
sourceInstaller = 'SMAP' //or 'PRIMARY' or 'NONE'
//whether to hide synthetic variables in the debugger
hideSyntheticVariables = false
}
}
My Xtend file:
package HelloWorld
class HelloWorld2 {
def static void main(String[] args) {
println("Hello")
}
}

Gradle dependencies in Idea project

I'm trying to use Gradle, but Idea dont see dependices. Here is my build.gradle
group 'me.ozka'
version '1.0.1'
buildscript {
ext.kotlin_version = '1.0.3'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.20'
compile 'org.eclipse.jetty:jetty-server:9.0.0.RC2'
compile 'org.eclipse.jetty:jetty-servlet:9.0.0.RC2'
}
When i'm trying import import org.eclipse.jetty.server.Server; Idea signal me an error. What i'm doing wrong?
upd: i'm also don't see jar files in Idea External library folder.
upd2: i'm add to build file apply plugin: 'jetty' and it's solve my problem!
You need to refresh your gradle dependencies.
Here are some ways of doing this.
Approach 1 (GUI):
Go to View -> Tool Windows -> Gradle
Click on the big refresh button (Refresh all gradle projects).
Approach 2 (Command):
gradle build --refresh-dependencies

How to run build.gradle with Sikuli integrated into the project?

I am using Sikuli in my project to handle some flash buttons. It's working fine while running scripts locally. The issue is that when I need to run the build.gradle, I need to have the Sikuli dependency in build.gradle. That is how I have written build.gradle. When I run the build, I get this error:
What went wrong: Could not resolve all dependencies for configuration ':compile'.
Could not find com.googlecode.javacpp:javacpp:0.1. Required by:
:new_qa_automation:1.0 > org.sikuli:sikuli-api:1.0.2 > org.sikuli:sikuli-c ore:1.0.1
Could not find com.googlecode.javacv:javacv:0.1. Required by:
:new_qa_automation:1.0 > org.sikuli:sikuli-api:1.0.2 > org.sikuli:sikuli-c ore:1.0.1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED.
Here is my build.gradle file
apply plugin: 'java' version = '1.0' apply plugin: 'project-report'
repositories { mavenCentral() maven { url
"http://repo.springsource.org/release" url
"http://oss.sonatype.org/content/groups/public/" } }
sourceCompatibility = 1.6 targetCompatibility = 1.6
configurations { cucumberRuntime { extendsFrom testRuntime } }
task test(overwrite: true) {
dependsOn assemble, processTestResources, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
//some args
systemProperties System.properties
}
} }
dependencies { compile 'org.seleniumhq.selenium:selenium-java:2.32.+'
compile 'org.apache.commons:commons-lang3:3.1' compile
'org.springframework:spring-context:3.2.3.RELEASE'
compile group: 'org.sikuli', name: 'sikuli-api', version: '1.0.+' compile group: 'commons-collections', name: 'commons-collections',
version: '3.+'
testCompile 'info.cukes:cucumber-java:1.1.2'
testCompile 'info.cukes:cucumber-spring:1.1.2'
testCompile 'info.cukes:cucumber-junit:1.1.2'
testCompile 'junit:junit:4.11' testCompile 'org.easytesting:fest-assert-core:2.0+'
}
Edit:
I added the URL for the Maven repositry. Now the error has changed to
ePage.java:9: error: package org.sikuli.script does not exist
import org.sikuli.script.FindFailed;
sikuli-script.jar in Sikuli IDE project not provide in any repository so you must use it like a 3rd party jar
see:
"Mavan's central repository will not answer on any Sikuli stuff" https://answers.launchpad.net/sikuli/+question/185713
"Gradle: Make a 3rd party jar available to local gradle repository" Gradle: Make a 3rd party jar available to local gradle repository
The Sikuli code base appears to be fragmented. It's quite confusing; I know of 3 different sets of Java bindings. (one, two, three)
I think the one you're pulling with Maven is this: http://code.google.com/p/sikuli-api/
If so, org.sikuli.script is not the right import. You don't include your code to show me what you're trying to do with Sikuli, but most of the things you'd want to import are somewhere under org.sikuli.api.
Just download the sikulix jar and mention it in build.gradle
eg: compile files('C:\Users\vedavyasa\Documents\jar\sikulixapi.jar')