Getting table cell value in Selenium C #

If I have a table in Selenium and I want to get a specific cell in a row, what will be the call to the corresponding method?

What confuse me is that the specific value I'm looking for appears more than once in the table, so how do I know which value is found?

Also, how can I pass credentials through basic auth?

thanks

+4
source share
2 answers

To get a specific cell using C # selenium, its selenium.GetTable("table.1.2") , where table is the name of the table, 1 is the row, and 2 is the cell.

eg.

  [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 main authorization situation, you will need to use http: // username: password@example.com as the URL where the username and password are on the page, but more and more browsers are starting to block this, so be careful. Where I work, we avoid this scenario.

+5
source

Try:

Iwebelement val = driver.FindElement (By.Id ("table #")); (Where # is equal to either 0,1,2) (parameterization does not matter how many tables)

Iwebelement val2 = val.By.XPath (".//tbody/tr/td [3]");

0
source

Source: https://habr.com/ru/post/1299439/


All Articles