How can I select this span element?
I am just starting with Selenium and now you need to select this element:
<span class=" close">Matrices</span>
This line of code returns null elements, so I assume this is not correct :-)
ReadOnlyCollection<IWebElement> matrixLink = driver.FindElements(By.PartialLinkText("Matrices"));
But I couldn’t find a suitable one other than Xpath, but it looks like this ( //*[@id=\"Navigation\"]/div[2]/div[2]/ul/li[7]/span) and it seems a little fragile for me?
EDIT : span has a class of "close". This is part of the menu, where there are 19 spans with the "close" class, so it is not a unique selector, unfortunately ....
This will work:
//*[@id=\"Navigation\"]/descendant::span[text()='Matrices']
, XPath, ... * all . , , , , div, :
//div[@id=\"Navigation\"]/descendant::span[text()='Matrices']
XPath , Navigation - , span, Matrices. descendant XPath . , , Navigation, - , TestDiv, Navigation, descendant , .
, By.PartialLinkText , . , , span span .
By.PartialLinkText By.LinkText "" , .