-1

I feel really stupid: I just read this question How to get html elements with multiple css classes and the answer was very clear and straightforward but when I try to apply it on this HTML

<div class="header group">

I am completely unable to make it work.

Here are some of the variations I have tried

//*[contains (@class, ’header’) and contains (@class, ‘group’)]
//div[contains (@class, ’header’) and contains (@class, ‘group’)]
//div[contains (@class, ’header’)]

What am I missing here? Should be straightforward, shouldn't it?

Testing in Chrome Canary.

Updates

  1. The invalid typographical apostrophes above happened when I copy-pasted into this form. I was using ' in the actual console.

  2. I was playing around on an archived version of the page at the Wayback Machine (WM) and nothing worked. However, when trying on the live version, everything worked as expected (the problem with the live version was that the final element I was "aiming" at currently is missing but will return later on, therefore I used WM). Any ideas why // seems broken on WM? Even if WM adds a few levels of divs, // should be transparent about that, shouldn't it?

d-b
  • 695
  • 3
  • 14
  • 43

2 Answers2

3

Just use this xpath.

//div[@class='header group']
KunduK
  • 32,888
  • 5
  • 17
  • 41
3

you should use something like this

<xpath expr="//div[hasclass('header') and hasclass('group')]" position="replace">
    <t>
        xxxxxx
    </t>
</xpath>