I am following a youtube video and trying to work on selenium java. When i tried running a feature file, i got this unsatisfiedLinkError. Can someone please help me why i am getting this error and how to resolve it.
Exception in thread "main" java.lang.UnsatisfiedLinkError: java.lang.Shutdown.beforeHalt()V
at java.lang.Shutdown.beforeHalt(Native Method)
at java.lang.Shutdown.exit(Unknown Source)
at java.lang.Runtime.exit(Unknown Source)
at java.lang.System.exit(Unknown Source)
at cucumber.api.cli.Main.main(Main.java:19)
Thank you.
What I have tried:
I added all the required dependencies to maven project and created feature file,pageObject class,stepDefinition and runner class.
Feature file:
Feature: Login feature
Scenario: Successful login with Valid credentials
Given user launch Chrome browser
When user opens URL "http://admin-demo.nopcommerce.com/login"
Then user enters Email as "admin@yourstore.com" and Password as "admin"
PageObject Class:
package pageObjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class LoginPage {
public WebDriver webdriver;
public LoginPage(WebDriver webdriver) {
this.webdriver = webdriver;
PageFactory.initElements(this.webdriver, this);
}
@FindBy(id="Email")
@CacheLookup
WebElement txtEmail;
public void setUserName(String username) {
txtEmail.clear();
txtEmail.sendKeys(username);
}
}
StepDefinition
package stepDefinitions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import pageObjects.LoginPage;
public class Steps {
public WebDriver webdriver;
public LoginPage lp;
@Given("^user launch Chrome browser$")
public void user_launch_Chrome_browser() throws Throwable {
System.setProperty("webdriver.chrome.driver", "E:\\Drivers\\chromedriver.exe");
webdriver = new ChromeDriver();
lp= new LoginPage(webdriver);
}
@When("^user opens URL \"([^\"]*)\"$")
public void user_opens_URL(String url) throws Throwable {
webdriver.get(url);
}
}
TestRunner:
package testRunner;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features=".//Features/Login.feature",
glue="stepDefinitions",
dryRun=false,
monochrome=true,
plugin= {"pretty","html:test-output"}
)
public class Runner {
}