How to select text under multiple “div-li-a href” using css in selenium web driver


Tags: selenium-webdriver,css-selectors

Problem :

I want to select the tag under li. I have tried with below css:

By.cssSelector("div.grid_10 div.box.round.first.fullpage div.block id.tabs-container a[text()='Active Companies/Filing']"))
<div class="grid_10">
 <div class="box round first fullpage">
   <h2>View Theme Information</h2>
   <div class="block ">
     <script type="text/javascript"> $(window).load(function() { $('#loading').hide(); }); </script>
     <div class="block" style="margin-bottom: 40px;">
       <div id="loading" style="display: none;">  
        <div id="tabs-container" style="height:500px;">
          <ul class="tabs-menu">
            <li class="">
            <li class="current">
              <a href="#secondtab">Active Companies/Filing</a>
            </li>

Please help?



Solution :

Actually there is no function text() in cssSelector. So using cssSelector you can't locate element with the text because there is no way to locate with inner text. You should try using xPath as below

By.xpath("//a[contains(text(),'Active Companies/Filing')]"))

Or

By.xpath("//li[contains(.,'Active Companies/Filing')]"))

Hope it helps...:)


    CSS Howto..

    How to Centralize a Float on the Screen (such horizontally as vertically) Using CSS

    How to style for only non-touch devices in css?

    Qt: Hower effect overlapped with selected tab

    How to control the appearance of a widget on client web sites CSS

    How do I center a character in a box using CSS?

    CSS: How to align table data

    How Do I Use Css To Select A Area Of Code

    How to properly position DIVS on a page to

    How do I align div vertically like in picture

    How to change the font size in table cells according to cells content?

    How to use top middle and center inside a div

    How to make text input line up with button in IE7?

    How do i make a flexible div with a background in css

    How to add ellipsis to table cells with dynamic width with only CSS?

    How to get div so it always reaches the bottom?

    How to select the first paragraph in a div with a specific class (CSS 2)

    How to apply css to a dynamically created div?

    How can I create CSS sprites from images stored in the database?

    html/CSS how to make a div always center when the window is resized [duplicate]

    how to create a table layout with float in css

    CSS: How to create vertical and horizontal grids on the same element?

    Using CSS how best to display name value pairs?

    how to I make my responsive website look normal on galaxy s4 (media query)

    Bootstrap with Picture Slideshow

    How can I have a transparent overlay and center with flex box?

    How to retain rectangular border around button when clicked

    How can I force text to “normal” (not bold) using css?

    How do I make a absolute positioned div have a width equal to it's parent minus some margin

    How to add composite css -webkit-mask-image?

    How do I change the overflow of a single element, while having the overflow of the body hidden?