0

Is there any possibility to fetch a unique value from one page and search the same unique number in the other page?

Workflow:

1.Entering details in a webpage (while entering the details, a unique number is generated in UI). 2.Navigate to other page and enter the generated unique number in a search box.

I am using selenium webdriver with cucumber tool for my test automation

Thanks.

| improve this question | | | | |
  • What kind of test you are writing? Is it an End to end flow? – Vishal Aggarwal Jan 5 '18 at 21:45
  • In terms of pure coding, it is always possible to store an value in a variable and use it later. – Vishal Aggarwal Jan 5 '18 at 21:46
1

It's possible.

Depending on the language and implementation of cucumber you're using, how you do it will vary, but assuming the process you're looking at is all inside one test, it will go something like this:

  • Enter details into the page
  • Read the unique number from the page (it should be stored in a local variable of some flavor)
  • Go to the next page
  • Enter the number in the local variable into the search field
  • Continue your test.

That said, this kind of workflow is getting rather complicated for UI level testing. Personally, since this seems to be a case of creating a record then searching for that record, I'd look at taking a different approach:

  • Test 1 - create the record and verify that a new unique identifier is generated.
  • Test 2 - search for an existing record with a known identifier and verify that you get the expected result.

To use this structure you will need to be sure you have a database that you control, but it makes for simpler - and therefore less fragile - tests.

| improve this answer | | | | |
0

In order to share the value of the variable between your Cucumber steps, you will have to share it in a variable that both steps have access to.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.