How to Fetch Text from two separate div's with same class name?

后端 未结 2 487
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 12:28

I have to fetch two labels \'Text 1\', \'Text 2\' which belongs to same class =\'xyz\', which are located in two div\'s.Structure as shown below.

2条回答
  •  一个人的身影
    2021-01-25 12:55

    Use FindElements method and then access to necessary div using index, e.g:

    var elements = driver.FindElements(By.CssSelector((".xyz"));
    //get text in first element;
    elements[0].getText();
    //in second
    elements[1].getText(); //etc
    

提交回复
热议问题