I want to find the element of this link "us states" in <h5>
. I am trying this in craigslist. Any help will be highly appreciated
Here is the url: http://auburn.craigslist.org/
<html class="">
<head>
<body class="homepage w1024 list">
<script type="text/javascript">
<article id="pagecontainer">
<section class="body">
<table id="container" cellspacing="0" cellpadding="0"
<tbody>
<tr>
<td id="leftbar">
<td id="center">
<td id="rightbar">
<ul class="menu collapsible">
<li class="expand s">
<li class="s">
<li class="s">
<h5 class="ban hot">us states</h5>
<ul class="acitem" style="display: none;">
</li>
<li class="s">
<li class="s">
This question is related to
selenium
webdriver
css-selectors
selenium-webdriver
By.cssSelector(".ban")
or By.cssSelector(".hot")
or By.cssSelector(".ban.hot")
should all select it unless there is another element that has those classes.
In CSS, .name
means find an element that has a class with name
. .foo.bar.baz
means to find an element that has all of those classes (in the same element).
However, each of those selectors will select only the first element that matches it on the page. If you need something more specific, please post the HTML of the other elements that have those classes.
You can describe your css selection like cascading style sheet dows:
protected override void When()
{
SUT.Browser.FindElements(By.CssSelector("#carousel > a.tiny.button"))
}
Source: Stackoverflow.com