Tuesday, July 7, 2015

C# Selenium - Combination of CSS Selectors

Sometimes when a particular selector matches more than one element, you may need to combine selectors to clarify things
Here is some of that syntax

Ex: <div id='party' class='btCls'>

css=div#party

driver.FindElement(By.CssSelector("div#party"))
In the above example, we are combining the div element selector with the party id selector

css=div.btCls

driver.FindElement(By.CssSelector("div.btCls"))
In the above example, we are combining the div element selector with the btCls class selector

css=div#party.btCls

driver.FindElement(By.CssSelector("div#party.btCls"))
In the above example, we are combining the div element selector with the party id selector & btCls class selector

0 comments