简体   繁体   English

我想使用C#中的Selenium从ID和行动态更改的列表中删除用户

[英]I want to delete a user from a list that ID's and rows change dynamically using Selenium in C#

I am in a web page with names and I have the Users name Test User99. 我在一个带有名称的网页中,并且具有用户名Test User99。 I want to use a selenium Webdriver/C# command to find that User and click the delete button next to him. 我想使用Selenium Webdriver / C#命令找到该用户,然后单击他旁边的删除按钮。 There are ID's but they are generated dynamically and the User and the button have different Id's and cells. 有ID,但是它们是动态生成的,并且用户和按钮具有不同的ID和单元格。 The Row could be different each time. 每次行可能不同。

听起来您可以使用XPath查找用户名,然后遍历DOM以获得删除按钮,但是如果没有HTML,我无法提供具体答案

            string pagesource = wd.PageSource;
            int username = pagesource.IndexOf("what you are looking for");
            string anything = pagesource.Substring(username - 60, 70);
            string buttonID = anything.Substring(anything.IndexOf("an ID"), 10);
            string buttonID2 = buttonID.Substring(0, buttonID.IndexOf('_'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM