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

Getting a null pointer exception when finding RadioGroup
Java parsing webpages in background
Display area isn't showing up when java Swing program is run
Juniversal Translator Error: The import org.junit cannot be resolved
Java/MongoDB - How to resolve error “exception: pipeline element 0 is not an object”
elasticsearch - Increment counter or create document if not exists
admob interstitial fill rates
Wro4j, webjars and font-awesome
Java Gson: Deserializing complex JSON string
Selenium grid, tests start starting on the same thread when run in parallel
Slenium Webdriver - Writing inside an iframe.
Finding integers in a txt file
How do I terminate a Java program if a certian condition isn't met?
Selenium CSS selector syntax for checking class and text both
NullPointerException in Rectangle class [duplicate]
Android gyroscope y-axis roll

Categories

HOME
isabelle
gremlin
dictionary
lodash
tesseract
q
amortized-analysis
leon
malloc
cakephp-2.5
sqlite3
sql-server-2016
mouse
here-api
gz
event-handling
flask-wtforms
ups
circuit
decimal
dosgi
libtiff
invantive-sql
propel
jprofiler
realex-payments-api
devops
h2db
numerical-methods
spark-jobserver
traffic
elasticsearch-net
bosh
pdb
scorm2004
fog
grails-3.1
phpfreechat
wpf-controls
retina-display
unspecified
webdriver-manager
broadcastreceiver
grid.mvc
.net-4.6.2
sas-jmp
qwt
long-polling
youcompleteme
komodoedit
boost-multi-index
dropbox-php
libusb-win32
vtigercrm
ableton-live
color-picker
log4c
sts-springsourcetoolsuite
nsviewcontroller
lua-5.1
actionbardrawertoggle
make-install
hexdump
revolution-r
kendonumerictextbox
reactive-banana
execute
wordml
ng-animate
has-many-through
sgen
poller
balanced-payments
viadeo
page-layout
ms-project-server-2010
commoncrypto
soundtouch
coverflow
interface-orientation
free-variable
specification-pattern
selected
chuck
libstdc++
asyncfileupload
spyware
yui-datatable
locate
dentrix
nsviewanimation
rescale
compiler-specific
aquaticprime
ubuntu-9.04
multiple-languages
document-conversion

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App