Domanda

I have been using css selectors as div and span till now while using Selenium WebDrivers with Ruby for testing.

However I have some dd and xmlns:dd attributes as well. Is it possible to have a css selector for this as well.

Html Code:

    <div class="class1 class2 class3 class4" style="padding: 4px;" id="_c04a6325-5316-4177-980f-38484eb27730"> 
      <span class="class5" style="font-weight: bold; text-decoration: underline;">Month</span> 
        <div class="class6" dd:contenttype="Month" dd:referenceuuid="1446A201-FD91-4A82-B645-  306DC948DC48" id="_3d510b04-8a5a-4bf9-bc7a-8efd55f9ca48">
          <div xmlns:dd="Week" class="class7 class8" dd:entityid="1457893" dd:contenttype="Monday" id="_7480bbe4-bbf0-4a54-8994-ae773b418470">
             Breakfast 
          </div> 
        </div>
      </span>
   </div>

What I presently do:

$driver.find_elements(:css, 'div.class7.class8')

What I want to do:

Something like this to use the data in dd:contenttype and/or xmlns:dd to find an element

$driver.find_elements(:css, 'div.dd:contenttype="Monday"')       OR
$driver.find_elements(:css, 'div.xmlns:dd="Week"')

Is the possible to find and element using dd:contenttype and/or xmlns:dd??

È stato utile?

Soluzione

use $driver.find_elements(:css, 'div[dd\\:contenttype="Monday"]')

for more information you can take a look on http://sauceio.com/index.php/2010/01/selenium-totw-css-selectors-in-selenium-demystified/

Altri suggerimenti

Try this way:

$driver.find_elements(:xpath, "//div[@class = 'class6 class7' and @dd:contenttype = 'Monday'")

The above should work.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top