我工作的自动化,获得的每次请您及时找到示例代码每个动态ID和..如何处理硒中的动态ID?
<li class="list-group-items pingMessage clearfix" id="59580" data-reactid=".c.$0.0.$59580"></li>
<li class="list-group-items pingMessage clearfix" id="59581" data-reactid=".c.$0.0.$59580"><li>
<li class="list-group-items myMessage pingMessage clearfix bunch" id="59588" data-reactid=".e.$0.0.$59578"></li>
每个<li>
项目有不同的ID。我想使用gettext
获取物品的ID值,然后将其存储在一个变量中,并拨打xpath
。
我尝试下面的代码:当你需要在这里
//Getting id of particular text
WebElement Id=driver.findElement("By.xpath(//*[@class='list-group-items myMessage pingMessage clearfix bunch']").getText();
//My problem starts here i want to pass the stored id as id value how can i do it..
driver.findElement("By.id("+Id+")).click;
我已经重新编写了一些问题,以提高可读性。 –