Reputation: 105
If I have a table in Selenium and I want to get a specific cell in a row, what would be the relevant method call?
What I am confused about is the specific value I am looking for comes up more than once in the table so how do I know which value is found?
Furthermore, how can I pass credentials via basic auth?
Thanks
Upvotes: 4
Views: 3938
Reputation: 29
Please try:
Iwebelement val = driver.FindElement(By.Id("table#")); (Where # is either 0,1,2)(parameterized doesn't matter how many tables)
Iwebelement val2 = val.By.XPath(".//tbody/tr/td[3]");
Upvotes: 0
Reputation: 22438
To get a specific cell using selenium C# its selenium.GetTable("table.1.2")
where table
is the name of the table, 1
is the row and 2
is the cell.
e.g.
[Test]
public void TableTest()
{
try
{
Assert.AreEqual("value that should be in the cell", selenium.GetTable("table.1.2"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}
}
To get around the basic auth situation you will need to use http://username:[email protected] as the url where username and password will get you through to the page but more and more browsers are starting to block this so beware. Where I work we avoid this scenario.
Upvotes: 5