I need to find a web element using CSS

0 votes

I need to find an element which has this within <h5> "us states". I am trying to do it in this url: http://auburn.craigslist.org/. Any help appreciated.

<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">
Apr 13, 2018 in Selenium by kappa3010
• 2,090 points
677 views

1 answer to this question.

0 votes

The element should be located with any of: By.cssSelector(".ban") or with By.cssSelector(".hot") or even with By.cssSelector(".ban.hot")

But if its not happenning, then any of the below should work:
With cssSelector:

IList<we> hotBanners = driver.FindElements(By.CssSelector(".ban.hot"));
we banUsStates = hotBanners[3];
And probaby only With XPath:
driver.FindElement(By.XPath("//h5[contains(@class, 'ban hot') and text() = 'us states']"));
answered Apr 13, 2018 by nsv999
• 5,500 points

Related Questions In Selenium

+1 vote
2 answers

Is it possible to manually set the attribute value of a Web Element using Selenium?

WebDriver driver; JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.getElementById('id123').setAttribute('attr', ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
26,738 views
0 votes
1 answer

How to mouse hover on a web element using Selenium WebDriver?

Hello Nitin, to automate mouse hovering over ...READ MORE

answered May 7, 2019 in Selenium by Anvi
• 14,150 points
6,194 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,711 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,608 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,680 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,551 views
0 votes
1 answer

I tried to open a new website when a new tab is opened using Selenium Webdriver

Try this code: ArrayList<String> tabs = new ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
3,985 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP