php - BDD Behat change expected value based on profile -


my behat feature file

scenario: verify docs    given i'm on "/docs"    should see "link1" link href of "https://server1.xyz.com/link1"    should see "link2" link href of "https://server1.xyz.com/link2"    should see "link3" link href of "https://server1.xyz.com/link3"    should see "link4" link href of "https://server1.xyz.com/link4"    should see "link5" link href of "https://server1.xyz.com/link5" 

the expected value links changes based on profile. say, if run using server1 profile, link i'm expecting link1 ""https://server1.xyz.com/link1" , if want run using server2 profile, link link5 i'm expecting ""https://server2.xyz.com/link5".

so possible use parameter file example

profile: server1 linkvar1: "https://server1.xyz.com/link1" linkvar2: "https://server1.xyz.com/link2"  profile: server2 linkvar1: "https://server2.xyz.com/link1" linkvar2: "https://server2.xyz.com/link2" 

and in feature file

given i'm on "/docs" should see "link1" link href of "%linkvar1%" should see "link2" link href of "%linkvar2%" 

or else suggest how can achieve in better way.

you have multiple option here:

1) check link page ( without base url ) can have step like:

i should see link contains "link1" 

in step href attribute , check parameter.

2) selector each link , check need (element exists/is visible). can have use steps like:

i should see "css_selector" element "css_selector" element should not visible 

of course selectors should based on href, like:

[href*='link1']  [href$='link1']

see more css selectors here: w3schools

3) if have different number of links can add parameter in behat.yml each profile, read parameter , use in control structure (if-else, switch). , can define step like:

the navigation menu should displayed 

or

the section_name section should displayed 

you can define parameters each profile, consider using them efficient possible, wouldn't want have behat.yml full of parameters.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -