📺 Develpreneur YouTube Episode

Video + transcript

WebDriver IO - Part 3

2022-07-19 •Youtube

Detailed Notes

In this presentation, we are going to be talking about using the WebDriver IO: Building Automation Scripts using Javascript. Now, this is not really going to be a slide-driven presentation. Instead, we are going to go through the website and talk about the different technologies, and things you can do with WebDriver. Then, we're going to jump into a full hands-on example, building your first project, and looking at some of the different ways you can use WebDriver for testing.

In the past, I've talked about code test frameworks. Such as, topics about the different ways you can build your tests, and how you should test. Plus, we've talked about different things like unit testing, PHP testing, JUnit, every language, essentially own way of testing, and JavaScript's, no different. So open up the link below and enjoy the presentation.

WebDriver IO: Building Automation Scripts in JS Overview:

What is WebDriver IO How to build tests. The different types of frameworks it supports Reporting Hands-on Demo

Transcript Text
[Music]
and the actual tests
now because i selected page objects it
actually built some default page objects
for me so it created a parent class
called page
which opens the path to the particular
page
and then we have the secure page so if
you have any secure information you can
define it here
again extends page
and then we have login page
so login page
has three fields that we're going to get
username password
and button type submit
so hashtag means that the id is username
hashtag username password
this is a
xpath lookup so we're looking for button
of type submit
so we have our selectors here
again these get loaded every time you
load
login page so you have to be careful
with this
again javascript not as heavy as java
but still you need to be conscious of
how many of these you load
now we have our login method so you
create an asynchronous login pass in
username and password and it will try to
login to the site so we do awaits this
and button submit
return super login
and we define our class
so now we come into our specs so here is
where we build our test case
so here's our test case we register our
two pages so we have login page secure
page
each of these goes to our specific page
then we describe
my login application
it should login with valid credentials
we do an asynchronous call
call login page open login page login
expect secure page so after we log in we
should get a secure page it should exist
and secure flush to have containing you
have logged into a secure area
all fairly readable and user friendly so
when you run this that is what we saw
now just some other quick examples
so if you
do appium or any mobile testing you can
download the appium template
follow the same type of model
it's got some additional configurations
for appium so you have different uh
types you want to include different
paths
uh and you have some other
pieces you can figure here
uh here's all the dependencies so we
need to
include a bunch of different uh scripts
and dev dependencies so appian browser
stack local runner mocha
saw service
babel config
so here
uh because we're dealing with mobile we
need some helpers so we have biometrics
some
constants some gestures
some utilities
that's if you're doing mobile
again we have page objects
so here again keeping it simple we can
do get username return username
get password return password very clean
page
now here's where things get a little
tricky if you are a cucumber fan
you have to build your features
and this is where
this gets a little ugly
so you can create your steps so here's
all your givens
here's your lens here's your lens
and then your features look something
like this
background given i open the site
scenarios and so on
the problem i have with cucumber is that
well this is very user friendly when you
get to the actual test components and do
your steps this is not always user
friendly especially even with page
objects
so
buyer beware if you try to use cucumber
for
testing especially with javascript and
selenium it it works it is functional if
you are a cucumber whiz by all means use
cucumber
it's just not my cup of tea i think
there's just way too much complexity
with setting things up
jasmine
not so bad so if you come in here go
into test
page objects again you follow the
standard pojos or i'm sorry page object
models
very clean very easy to read
and then your specs
are again
very easy so here is our test
step
or i'm sorry here's our test case with
two use cases inside of it
so auth form should deny access with
wrong credentials and should allow
access with correct crunch credentials
so can it and if then
dynamic
check box
and then web drive web driver master so
we have typescript
we can do mocha
test sample test
again
fairly easy to read
and typescript syntax a little
easier to read a couple additional
features there
can include docker i thought this was
cool
so here's our docker test but then
here's all your docker setup information
so if you do docker
you could actually run this test it will
build a docker
it includes the docker file it'll run
the little nugget it'll run the little
docker container for you and then
they'll run your tests inside of your
doctor so it's completely self-contained
so this was really cool i like this
option and idea
and it builds it for you out of the box
so you don't have to configure anything
so if you're not a doctor fan or you
just are new to docker
highly recommend this check this out
again cucumber if you like cucumber
and i showed you jasmine
so that's kind of web driver in a
nutshell
do we have any
questions
if anybody's asking questions they are
on mutes
uh now this is
um
it's just one of those
particularly as you go through some of
these features it's just amazing how
much
functionality and features are just
you know really quick to
to fire up as far as you know related to
testing and things like that
particularly and i'd run into
a while back mocks and spies and things
like that where
um it's just
it is amazingly easy it's surprising now
that some people you know the people
don't particularly in commercial or
professional development don't include
test scripts and regression on a regular
basis because it's just
the power of some of this that is just
amazing
so great presentation
uh dave any questions
yeah can you build a full application
using just the web driver ioi
uh well it's not so much an application
you're building the
test
okay application to test an application
uh so it's it's building your whole test
suite for you but then you have to go
wired up with the page objects and um
your actual test scripts
so it does test everything like the rpm
and all the accelerator and all those
different applications
yes it can um integrate with any of
these you just have to do the setup so
you have all these different services
here you can integrate with appium
browser stack
devtools firefox sauce labs
visual code like i showed you chrome
driver so you have access to all of
these which is really slick
and
the reason they have access to all of
this is because
web i or webdriver io essentially
incorporates and uses that node.js
if it didn't use node.js i don't think
it would have the capabilities that it
does
okay gotcha
cool thanks
yeah no problem
so if there are no more questions just
to quickly recap so webdriver io is a
very useful front-end test framework for
nodejs
it is really useful for shops that are
front end development heavy meaning that
everyone does html
javascript
uh css xml essentially it's all front
end there's no back end heavy lifting
either through c sharp
java anything of that nature
with that being said though
webdriver i o essentially
is a javascript wrapper around the
selenium web driver so if you are a more
complex shop and you have a lot of back
end developers and a lot of back end
features using things like c sharp and
java i would recommend not using web
driver i o and go and just use the
selenium webdriver classes and packages
for your particular language
reason is
typically when you have things like this
that are wrappers around another
technology you never know when they're
gonna go away or not be supported or the
core feature that they're wrapped around
changes something that breaks this
integration piece so it's just something
to be careful of
if you're looking to use this type of
feature
for your testing so that's a wrap i'd
like to thank you all for your time if
you would like to discuss any of these
topics or other topics you can reach us
at the following we're at info
developer.com
you can reach us on our developer.com
website on our contact us page
you can tweet us at developernerd you
could also find us on facebook at
facebook.com developerner
our videos are available on vimeo and
youtube just search for developer nerd
our goal is making every developer
better thank you and have a wonderful
day
[Music]
you
Transcript Segments
0.43

[Music]

28.64

and the actual tests

30.48

now because i selected page objects it

33.44

actually built some default page objects

36.32

for me so it created a parent class

39.76

called page

40.96

which opens the path to the particular

43.44

page

46.719

and then we have the secure page so if

49.68

you have any secure information you can

52

define it here

54.48

again extends page

56.399

and then we have login page

58.8

so login page

60.719

has three fields that we're going to get

63.359

username password

65.439

and button type submit

69.28

so hashtag means that the id is username

72.72

hashtag username password

75.04

this is a

77.28

xpath lookup so we're looking for button

79.439

of type submit

81.92

so we have our selectors here

85.04

again these get loaded every time you

87.92

load

89.28

login page so you have to be careful

91.2

with this

92.159

again javascript not as heavy as java

94.88

but still you need to be conscious of

96.72

how many of these you load

99.04

now we have our login method so you

102.32

create an asynchronous login pass in

104.479

username and password and it will try to

106.799

login to the site so we do awaits this

110.24

and button submit

112.96

return super login

114.96

and we define our class

117.92

so now we come into our specs so here is

120.64

where we build our test case

125.6

so here's our test case we register our

128.239

two pages so we have login page secure

131.039

page

132.239

each of these goes to our specific page

135.2

then we describe

137.44

my login application

139.599

it should login with valid credentials

142.4

we do an asynchronous call

144.64

call login page open login page login

148.8

expect secure page so after we log in we

152.56

should get a secure page it should exist

156

and secure flush to have containing you

158.879

have logged into a secure area

161.2

all fairly readable and user friendly so

164.16

when you run this that is what we saw

169.599

now just some other quick examples

172.239

so if you

173.92

do appium or any mobile testing you can

177.84

download the appium template

180.4

follow the same type of model

182.56

it's got some additional configurations

184.879

for appium so you have different uh

187.28

types you want to include different

189.36

paths

190.64

uh and you have some other

192.64

pieces you can figure here

195.36

uh here's all the dependencies so we

198.159

need to

199.2

include a bunch of different uh scripts

203.92

and dev dependencies so appian browser

206.319

stack local runner mocha

208.64

saw service

212.08

babel config

216.159

so here

218.4

uh because we're dealing with mobile we

220.56

need some helpers so we have biometrics

224.159

some

224.84

constants some gestures

227.92

some utilities

229.599

that's if you're doing mobile

231.519

again we have page objects

233.84

so here again keeping it simple we can

236.959

do get username return username

239.68

get password return password very clean

243.76

page

244.959

now here's where things get a little

246.48

tricky if you are a cucumber fan

249.84

you have to build your features

252.48

and this is where

255.599

this gets a little ugly

257.68

so you can create your steps so here's

260.079

all your givens

263.84

here's your lens here's your lens

267.68

and then your features look something

269.52

like this

270.96

background given i open the site

274

scenarios and so on

276.72

the problem i have with cucumber is that

279.52

well this is very user friendly when you

282.479

get to the actual test components and do

285.36

your steps this is not always user

288

friendly especially even with page

289.919

objects

291.12

so

292.24

buyer beware if you try to use cucumber

294.56

for

295.36

testing especially with javascript and

299.199

selenium it it works it is functional if

302.56

you are a cucumber whiz by all means use

306.16

cucumber

307.28

it's just not my cup of tea i think

310.56

there's just way too much complexity

312.56

with setting things up

315.12

jasmine

316.639

not so bad so if you come in here go

318.96

into test

320.16

page objects again you follow the

322.639

standard pojos or i'm sorry page object

325.44

models

328.08

very clean very easy to read

331.12

and then your specs

334.639

are again

335.84

very easy so here is our test

339.199

step

341.36

or i'm sorry here's our test case with

344

two use cases inside of it

346.8

so auth form should deny access with

348.96

wrong credentials and should allow

350.96

access with correct crunch credentials

353.44

so can it and if then

356.88

dynamic

360

check box

362.96

and then web drive web driver master so

366.16

we have typescript

367.919

we can do mocha

370.08

test sample test

372

again

373.039

fairly easy to read

375.12

and typescript syntax a little

378.24

easier to read a couple additional

380.319

features there

383.759

can include docker i thought this was

385.84

cool

386.96

so here's our docker test but then

389.28

here's all your docker setup information

391.44

so if you do docker

393.039

you could actually run this test it will

394.8

build a docker

397.12

it includes the docker file it'll run

402.08

the little nugget it'll run the little

404.24

docker container for you and then

406.56

they'll run your tests inside of your

408

doctor so it's completely self-contained

410.24

so this was really cool i like this

412.56

option and idea

414.24

and it builds it for you out of the box

416

so you don't have to configure anything

417.52

so if you're not a doctor fan or you

419.759

just are new to docker

421.44

highly recommend this check this out

424.319

again cucumber if you like cucumber

426.96

and i showed you jasmine

429.28

so that's kind of web driver in a

430.8

nutshell

432.16

do we have any

434.24

questions

439.759

if anybody's asking questions they are

441.52

on mutes

442.88

uh now this is

444.56

um

446.72

it's just one of those

448.56

particularly as you go through some of

449.52

these features it's just amazing how

451.52

much

453.52

functionality and features are just

456.08

you know really quick to

458.319

to fire up as far as you know related to

460.16

testing and things like that

461.919

particularly and i'd run into

464.4

a while back mocks and spies and things

466.8

like that where

468.24

um it's just

470.08

it is amazingly easy it's surprising now

472.8

that some people you know the people

474.16

don't particularly in commercial or

476.56

professional development don't include

479.199

test scripts and regression on a regular

481.84

basis because it's just

483.52

the power of some of this that is just

485.68

amazing

487.44

so great presentation

491.599

uh dave any questions

493.44

yeah can you build a full application

495.52

using just the web driver ioi

499.12

uh well it's not so much an application

500.96

you're building the

502.8

test

504.4

okay application to test an application

507.599

uh so it's it's building your whole test

509.44

suite for you but then you have to go

511.36

wired up with the page objects and um

513.68

your actual test scripts

522.719

so it does test everything like the rpm

524.959

and all the accelerator and all those

527.04

different applications

529.12

yes it can um integrate with any of

531.92

these you just have to do the setup so

534.32

you have all these different services

536

here you can integrate with appium

538.16

browser stack

539.6

devtools firefox sauce labs

542.64

visual code like i showed you chrome

545.279

driver so you have access to all of

547.279

these which is really slick

550.16

and

551.2

the reason they have access to all of

552.959

this is because

555.2

web i or webdriver io essentially

558.24

incorporates and uses that node.js

561.76

if it didn't use node.js i don't think

563.68

it would have the capabilities that it

565.68

does

568.56

okay gotcha

570.399

cool thanks

572

yeah no problem

576.32

so if there are no more questions just

578.64

to quickly recap so webdriver io is a

582.16

very useful front-end test framework for

585.839

nodejs

587.36

it is really useful for shops that are

590.48

front end development heavy meaning that

593.279

everyone does html

595.6

javascript

596.959

uh css xml essentially it's all front

600.24

end there's no back end heavy lifting

602.64

either through c sharp

604.56

java anything of that nature

607.68

with that being said though

610.079

webdriver i o essentially

612.56

is a javascript wrapper around the

615.519

selenium web driver so if you are a more

618.64

complex shop and you have a lot of back

620.959

end developers and a lot of back end

623.279

features using things like c sharp and

626.32

java i would recommend not using web

629.12

driver i o and go and just use the

631.76

selenium webdriver classes and packages

634

for your particular language

636.399

reason is

637.839

typically when you have things like this

639.44

that are wrappers around another

641.2

technology you never know when they're

643.519

gonna go away or not be supported or the

646.72

core feature that they're wrapped around

648.72

changes something that breaks this

651.04

integration piece so it's just something

653.2

to be careful of

654.8

if you're looking to use this type of

656.88

feature

657.92

for your testing so that's a wrap i'd

660.8

like to thank you all for your time if

662.72

you would like to discuss any of these

664.32

topics or other topics you can reach us

666.8

at the following we're at info

668.959

developer.com

670.64

you can reach us on our developer.com

673.04

website on our contact us page

675.68

you can tweet us at developernerd you

678.8

could also find us on facebook at

680.959

facebook.com developerner

683.519

our videos are available on vimeo and

686.88

youtube just search for developer nerd

689.44

our goal is making every developer

691.04

better thank you and have a wonderful

693.04

day

696.08

[Music]

710.639

you