import geb.Browser
import org.openqa.selenium.firefox.FirefoxDriver
Browser.drive {
go "google.com"
}
I run the script above and get the following error:java.lang.NoClassDefFoundError: org/openqa/selenium/TakesScreenshot
As it says on the documentation page (and in it's maven info), you need:
org.codehaus.geb:geb-implicit-assertions:0.7.2
org.seleniumhq.selenium:selenium-api:2.15.0
org.seleniumhq.selenium:selenium-support:2.15.0
selenium-api depends on google guava
and selenium-support depends on junit and hamcrest
You'll also need to add groovy to the classpath as geb uses it under the covers
Related
I'm upgrading a cucumber project to cucumber 6. But after the upgrade intellij doesn't recognize my steps anymore. When I run via my pom there is no issue. But if you try to go to the step definition from the feature file intellij says that there is no stepdefintion
My runner is like this
package be.nbb.hive.cucumber;
import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
#RunWith(CucumberWithSerenity.class)
#CucumberOptions(
plugin = {"pretty"},
features = "src/test/resources/features",
glue = {"be.nbb.hive.cucumber.Steps"}
)
public class CucumberTestSuite {}
And my steps are in the package
package be.nbb.hive.cucumber.Steps;
Is this the issue or is it something else that blocks the recognision?
I had similar issue. Installing cucumber for java and gherkin IntelliJ plugins from marketplace resolved it for me
I'm trying to develop an intellij plugin written in kotlin - I'm struggling to find any examples of unit tests for the plugin that are written in kotlin, or even java ones with test data that are written using gradle rather than the older dev SDK. Is anyone able to point to a demo application with unit tests? (For inspections, ideally)
Some theory:
Testing in Gradle
Add test classes to a Gradle project
Testing Gradle plugins
Running JUnit5 tests with Gradle
Unit testing in Kotlin and kotlin.test library
Using Gradle with Kotlin
Code samples:
Article on running Kotlin Unit tests with Gradle
A tutorial on building apps with Spring Boot and Kotlin with a section on testing with Junit5
Custom Gradle plugin example
Hope this helps.
These come out of the box now if you use the template: https://github.com/JetBrains/intellij-platform-plugin-template
Here's one of the tests in Kotlin:
package org.jetbrains.plugins.template
import com.intellij.ide.highlighter.XmlFileType
import com.intellij.psi.xml.XmlFile
import com.intellij.testFramework.TestDataPath
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.util.PsiErrorElementUtil
class MyPluginTest : BasePlatformTestCase() {
fun testXMLFile() {
val psiFile = myFixture.configureByText(XmlFileType.INSTANCE, "<foo>bar</foo>")
val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java)
assertFalse(PsiErrorElementUtil.hasErrors(project, xmlFile.virtualFile))
assertNotNull(xmlFile.rootTag)
xmlFile.rootTag?.let {
assertEquals("foo", it.name)
assertEquals("bar", it.value.text)
}
}
}
The plugin documentation also provides more relevant info for testing: https://plugins.jetbrains.com/docs/intellij/writing-tests.html
Also, here are some unit tests written in Java for the JUnit IntelliJ plugin https://github.com/JetBrains/intellij-community/blob/master/plugins/junit/test/com/intellij/execution/junit/JUnitDetectionTest.java
I am currently working on creating a Test Suite using Cucumber framework. I have created feature files for each of the functionality I have to test.
The feature file never shows the conditions to be covered via glue code. On click of Recalculate steps it throws an error : An internal error occurred during: "Scanning for step definitions".
java.lang.NullPointerException
I tried to change the path of glue in the Test Runner class but it did not solve the problem as well. The feature can be executed without any issue and the code runs fine, only issue is feature files keep on stating that there is no matching glue code.
#OrderInteraction
#Orders
Feature: Validating Order functionality
Background: Pre-requisites of Order Functionality
Given WebDriver is initialized
And Website is up and running
When User Enter "Username" and "Password" as Credentials
Then Validate User Login
Test Runner :
package Cucumber;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
#RunWith(Cucumber.class)
#CucumberOptions(features = "Features", glue=
{"src/main/java/CucumberStepDefinitions"})
public class CucumberTestRunner {
}
I would like to find a way in which Cucumber feature files can recognize the glue code present. Feel free to guide me to a existing question which answers this or a documentation which will be of help.
There is a possible solution in this discussion https://github.com/cucumber/cucumber-eclipse/issues/303
Which basically says to make sure you don't have
import cucumber.api.java.en.*;
in your steps files, and to use
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
instead.
Which fixed it for me
I finally was able to find the solution to this issue. Issue lies with the cucumber plugin version, I referred to Cucumber-Eclipse-Update-SiteSnapshot for resolution.
The steps were as below :
1.From Eclipse, go to menu Help > Install New software
2.Work with: https://cucumber.github.io/cucumber-eclipse-update-site-snapshot
3.Select the check-box for Cucumber Eclipse Plugin
4.Select Next as per the instruction shown during installation.
5.Restart your Eclipse after completion of instruction.
Once the plugin was updated Feature file automatically scanned for steps and found the matching glue code.
I would like to know if it's possible to run a WebDriver test in Java using just a plain text editor, Firefox browser, Java SDK and WebDriver JAR?
I am trying to come up with the most "bare-metal" way to run a test without adding Test Runners, Test Frameworks, Dependency Managers into the mix.
I understand that this is not the "right" way to do things, but I am trying to find a way to create a new kind of WebDriver tutorial that will focus only on the API.
I am using OS X right now but instructions for Windows would be equally appreciated.
Running WebDriver is as simple as
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
}
The only thing that you need is a correct classpath, which is just selenium-java-2.38.0.jar and supporting libraries, namely: guava-15.0.jar json-20080701.jar commons-exec-1.1.jar httpcore-4.3.jar httpclient-4.3.1.jar commons-logging-1.1.1.jar
Or, as per JimEvans, you can download standalone selenium-server-standalone-2.40.0.jar that has all dependencies included.
Firstly record and run the script you want to do then export it as junit4 test suite and save. Second copy the full code and aste it in eclipse then you can get the option "Run as junit4 test" while running code.
I am using junit 4.8 and intellij 8 and i would like to only run tests inside the IDE which are named something like *UnitTest.java.
How can this be achieved?
Found a solution with cpsuite. http://www.johanneslink.net/projects/cpsuite.jsp
Pitty it's not in the maven repo.
import org.junit.extensions.cpsuite.ClasspathSuite;
import org.junit.runner.RunWith;
#RunWith(ClasspathSuite.class)
#ClasspathSuite.ClassnameFilters(".*UnitTest")
public class UnitTestSuite {
}