0

I have two scenarios for two pages (homepage and property page). And in these scenarios I have the same steps (I fill in "field" with "text"). I need to implement one for homepage and one for property page. But behave sees only one implementation. How could I do the different implementation for the same named steps? I dont want to do hardcode and call the same action differently.

My stack: behave + python + selenium + pageObject

1 Answers1

0

Somehow, somewhere, you have to put in code to say the things are different.

  • Add another variable to the statement (I fill in "field" on "page" with "text")
  • Use two statements (I fill in homepage "field" with "text" && I fill in property "field" with "text")
  • Add logic to the method to dynamically figure out what page it is looking at to know what field is which

All have advantages and drawbacks. You'll need to decide which works best for your situation. The problem with having a generic statement is that it can be applied to too many areas and eventually something has to give.

MivaScott
  • 1,763
  • 1
  • 12
  • 30
  • Do you mean I should use instead of "I click on 'search_button' on homepage and I click on 'search_button' on property" instead of "I click on 'search_button'?(it is other step) But is it not hardcode? – Heik Kerimov Jan 06 '18 at 09:07
  • @HeikKerimov As stated, you have three options. But every option requires hard coding of some kind. Making separate statements for each page is one of them. – MivaScott Jan 06 '18 at 23:40