I was asked in an interview this question

That two different scenario requires data from a common sheet. How to we identify that data already used , while passing it as input.

In general how to identify the data is already used and we need to select another record from data sheet.

  • 1
    This is a common programming question, unrelated (or not specific) to selenium. There are zillions of answers to it on Stack Overflow. – Peter M. - stands for Monica Oct 5 '17 at 14:28
  • Can @PeterMasiar you please help me with link for the answer. As my interviewer asked we have an option in selenium – Abhishek Kumar Oct 5 '17 at 14:31
  • 1
    Selenium is for browser automation. It can be used from many programming languages, which might have different way to identify duplicate entries in input sheet. It might been a trick question, with right answer being first sentence of this comment. – Peter M. - stands for Monica Oct 5 '17 at 14:51

Let me try.. It always depends on type of data and purpose so without looking to it we can't give exact answer except we can answer as an interview question like below.

  1. Assume data having some id then you can cross check by id that scenario2 used this id? If yes then skip it for scenario1.

  2. When parsing of data, after using row1 data put some flag that row1 is used at scenario1 so scenario2 can skip it.

There could be other way as well but again without understanding requirement its hard to say how? You should have asked more information in the interview to get more details :)

| improve this answer | |

That sounds almost like a trick question, if I understand it correctly. If each row may be used only once, then the rows should be specific for a test and not in a common sheet (do you see the contradiction? ;).

Having a common set of data for multiple tests can be fine if all tests are allowed to that same data (e.g. default values for an address). This simply sounds like bad design.

Now, it is possible (if it wasn't a trick question) that the intent is to add some data variability to the tests (e.g. 10 sets of data, randomly divided among 10 tests every time). If that's the case, the data is either consistent (if it influences the test outcome, e.g. discount values for an order) or not important (if it doesn't influence the test outcome, e.g. a street name). In both of these cases, you should use existing 'random data generators' that return random data and/or write your own where necessary.

| improve this answer | |
  • I think it was a trick question. He said we have something in selenium which validates whether the input is duplicate or not or already used for other case or same case. – Abhishek Kumar Oct 5 '17 at 14:26

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