Your css locator is wrong:
driver.FindElement(By.CssSelector("class[onclick='gotoReportView(20, 'ReportSectionc5404625cccfdb7d5563')']")).Click();
driver.FindElement(By.CssSelector("Span[onclick='gotoReportView(20, 'ReportSectionc5404625cccfdb7d5563')']")).Click();
The format for css locator is ,
- tag[attribute='value']
- tag.classname
- tag#id
- Tag>Tag (direct child)
- tag tag (in direct child , equvalent to /tag//tag in xpath)
- tag[attribute*='value'] ( Similar to contains in xpath, it search for partial match)
- tag[attribute^='value'] ( find attribute that start with particular value)
So the correct css locator is:
driver.FindElement(By.CssSelector("span[onclick=\"gotoReportView(20, \'ReportSectionc5404625cccfdb7d5563\')\"]")).Click();
Or
driver.FindElement(By.CssSelector("span[class='item'][onclick=\"gotoReportView(20, \'ReportSectionc5404625cccfdb7d5563\')\"]")).Click();
Note: you should escape the quotes (\') as there are quotes within the locator
And also use " quotes for the value Eg "[attribute=\"somthing(\'something\')\"]"
So just use the locator as it is in the DOM, and escape inner quotes using '\'