Click here to Skip to main content
15,884,664 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

Java
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

Java
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 {
}
Posted
Updated 9-Jun-21 4:54am
v8
Comments
Richard MacCutchan 9-Jun-21 11:33am    
Please do not remove the content of your question. If you have solved it then just mark it as solved.

1 solution

Quote:
I am following a youtube video

Since we have no idea what that video is telling you we cannot possibly guess what is wrong with your code.
It may be that some part of the code has registered a shutdown hook, but forgot the implementation. You should talk to the person who posted the video.
 
Share this answer
 
Comments
Member 15232840 6-Jun-21 7:32am    
Hi Richard, Thank you the reply. I have now updated my question and added the code that i tested. Please let me know if there is any change that i need to do
Richard MacCutchan 6-Jun-21 8:27am    
As I said above, you should talk to the person who posted the video. There is possibly something missing in the framework code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900