Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# noob来自行中的单元格_C#_Selenium_Xpath_Selenium Webdriver - Fatal编程技术网

C# noob来自行中的单元格

C# noob来自行中的单元格,c#,selenium,xpath,selenium-webdriver,C#,Selenium,Xpath,Selenium Webdriver,我正试图从表格中获取数据。我有这个表,可以迭代行 我在行中循环,试图通过唯一的标题值查找单元格。每列都有一个唯一的标题: 所以我想要的代码将 string strSequence = allRows[z].FindElement(By.XPath(.... something...)).Text; 其中搜索从当前行开始 string strSequence = allRows[z].FindElement(By.XPath("/td[@heading='colSequence']")); 其

我正试图从表格中获取数据。我有这个表,可以迭代行

我在行中循环,试图通过唯一的标题值查找单元格。每列都有一个唯一的标题:

所以我想要的代码将

string strSequence = allRows[z].FindElement(By.XPath(.... something...)).Text;
其中搜索从当前行开始

string strSequence = allRows[z].FindElement(By.XPath("/td[@heading='colSequence']"));
其中allRows[z]是一个行IWebElement


我刚刚在C语言中使用XPath时大脑抽筋。谢谢。

你能发布完整的代码吗?您尝试了什么?能否发布正确的应用程序html片段?请在代码中添加一些解释,用英语描述问题的根源并提交更改。英文版本是我不理解Selenium for C的XPath语法。如果为a提供了IWebElement,如何构造XPath以从headers属性中查找其中的。谢谢//tr[contains.,'colSequence']
//Taking all the table rows in list collection.    
IList<IWebElement> tableTR = driver.FindElement(By.Id("TABLE_ID")).FindElements(By.TagName("tr"));

    //Loop on rows
    foreach(IWebElement element in tableTR)
    {
    //for every row if the header tag equals what you need you do the code inside.
    if(element.GetAttribute("headers").Equals("colSequence")
    {
    //do your stuff...
    }
    }