java


Cucumber 'After' Hook not working?


Cucumber 'After' Hook not working?
I have a DriverFactory class which performs the setup etc as listed below however once all steps have been executed the 'Cucumber After' method dosnt seem to work which is housed in the DriverFactory?
I want a master hooks class 'Before' 'After' etc etc which will stop code duplication within Step files
public class DriverFactory {
protected WebDriver driver;
protected BasePage basePage;
protected LoginPage loginPage;
public WebDriver getDriver() {
if(driver == null) {
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\src\\test\\java\\resources\\other\\chromedriver.exe");
this.driver = new ChromeDriver();
this.driver.manage().window().maximize();
this.driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
}
return this.driver;
}
public WebDriver returnDriver() {
return this.driver;
}
#After
public void test() throws Throwable {
this.driver.close();
this.driver.quit();
}
}
public class LoginSteps {
DriverFactory driverFactory = new DriverFactory();
WebDriver driver = driverFactory.getDriver();
#Given("^User navigates to the \"([^\"]*)\" website$")
public void user_navigates_to_the_website(String url) throws Throwable {
BasePage basePage = new BasePage(driver);
basePage.loadUrl(url);
}
#And("^User entered the \"([^\"]*)\" username$")
public void user_entered_the_username(String username) throws Throwable {
LoginPage loginPage = new LoginPage(driver);
loginPage.setUsername(username);
}
I guess, the global hooks are not supported by Cucumber-jvm. However, there are some workarounds available. Please refer to link1 and link2 for details about the workarounds.

Related Links

Spring Boot - long running application for non-web app
Apache Storm Bolt task is not receiving message after some time
Enemy's speed when following player
Can this sum of squares of digits of a number puzzle's solution be optimized further?
How to extract 4 digit number after a certain word using Regex in java? [duplicate]
Integrate redis with spring boot
“Bad class file magic” from setting up Android Studio for NDK
Is there a way to check of .jar is in development mode still or in designer in IDE?
XML Parsing in hadoop/pig
Issues trying to respond to command-line user input
in createFile method templateArr shows null. why?
Why is my regex failing in shell script although it is working in jregex?
How can I compare text field and password field to String values?
ORMLite DataType.SERIALIZABLE HashMap not working
PayPal transaction has expired
Java: JDialog Closing Issue

Categories

HOME
multithreading
jdo
clips
asp.net-core
path-finding
relative-path
fft
bpmn
react-router
yahoo-oauth
cmd
paw-app
rubygems
jgroups
survey
blueprintjs
windows-server
add
applepay
usergrid
hex-editors
saxon
angular-ui
undefined
sms-gateway
openedx
alpine
jtextfield
custom-wordpress-pages
paging
errorlevel
intentfilter
functional-testing
ehcache
csrf-protection
sox
jndi
sqlcipher
numerical-methods
wpfdatagrid
uninstall
log4js-node
webkitspeechrecognition
windowbuilder
c++-amp
quote
srcset
sql-server-2012-express
junit5
airconsole
titanium-mobile
contact-form
repo
gammu
force-layout
appfabric
android-browser
starteam
sharefile
broadcastreceiver
particles.js
password-encryption
integrity
csound
worker-thread
crypt
pearson
bind9
dynamics-sl
redundancy
slicknav
django-debug-toolbar
impresspages
angstrom-linux
nsviewcontroller
persist
dataview
eclipse-clp
libressl
rgeo
ideamart
mono-embedding
processmodel
notify
pick
knuth
hyprlinkr
ms-project-server-2010
jmapviewer
web2py-modules
dbconnection
eventual-consistency
mylyn
yui-compressor
plasma
robotics-studio
hamiltonian-cycle
unc
newtonscript
twrequest
errai
dotnethighcharts
php-parser
doh
actionview
remember-me
nhibernate.search
preference
fixed-width
zend-tool
sef
3gp
document-conversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App