Search code examples
c#visual-studio-2010watin

how to select div class with same names?


Using Watin and VS C#. I am working on a test for a website. I have been able to open different pages using Div, Find.ById and so on ans so forth. This is where I need some directions. I need to open these pages but they all have same Id and class, so of course I am only able to open the first one, so here my questions: Any statement on Watin that can open the second or third? and/or any statement that will open when it founds the second or third or.... iteration of the same class/Id? Thank you


Solution

  • You can use Find.ByIndex contraint along with your id's or class names etc... If you need to click on the second element which has same id, then you need to pass index as 1 like...

    ie.TextField(Find.ById("someid")) --> This will return first element which has 'someid' as id of the lement.
    ie.TextField(Find.ById("someid") && Find.ByIndex(1)) --> This will return you the second element of 'someid'.