xPath contains() @class does not work properly

Fixed, not yet flighted Issue #8503401


Christiane S.
Aug 16, 2016
This issue is public.
Reported by 6 people

Sign in to watch or report this issue.

Steps to reproduce

General repro (does not require Web Driver):

Edge: repro
Chrome: no repro

Original Repro:
If you try to find an element with xPath where you search a substring of the class the element can not be found.


<div class="foo-bar test">

This does not work:
Driver.FindElement(By.xpath("//div[contains(@class, ‘foo’)]"))

This works:
Driver.FindElement(By.xpath("//div[contains(@class, ‘foo-bar’)]"))


0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Brad E.”

      Changed Assigned To to “Travis L.”

    • i have around 12 automation scenarios all work fine in other browsers like Chrome, in Edge they all fail because of the xpath locators do not work in Edge.

      trying to narrow down the discrepancy with edge, any suggestions ???

      environment details:
      Edge driver 2.0 windows 10 enterprise, version 1511, os build 10586.679

    • I have the same issue.

      This doesn’t work either.
      Driver.FindElement(By.xpath("//div[contains(@class, ‘foo-bar test’)]"))

      But these are fine.
      Driver.FindElement(By.xpath("//div[@class=‘foo-bar test’]"))

    • Our company is currently blocked in extending much of our test automation effort to cover Microsoft Edge because of this issue. Much of our internal framework code heavily leverages the XPath contains() function, and Edge is the only browser we’re contractually obligated to support that does not evaluate these XPaths correctly. This ticket has been open for over a year, is there any update on it?

    • For some more context, our front end is Angular 4 with an in-house component library that extends Angular Material. We experience this issue automating Edge v15 via Selenium WebDriver and XPath selectors that evaluate a class substring using the contains(@class,’foo’) function.

      Given the following example, where Angular Material renders overlay elements in their own cdk-overlay-container adjacent to the Angular root in the DOM, the XPATH selector for this could be:

      // NoSuchElementException thrown

      That XPath, however, does NOT locate the element. An equivalent CSS selector does, though:

      // find our element
    • Microsoft Edge Team

      Changed Assigned To from “Travis L.” to “Arthur B.”

      Changed Status to “Confirmed”

      Changed Steps to Reproduce

      Changed Title from “FindElement with xPath does not work properly - contains @class” to “xPath contains() @class does not work properly”

      Changed Status from “Confirmed” to “In progress”

      Changed Status from “In progress” to “In code review”

      Changed Status from “In code review” to “Fixed”

      Changed Status from “Fixed” to “Fixed, not yet flighted”

    • This bug should be fixed in the next release of Edge.

    • Will this be available with windows 10 update 17025?

    • It doesn’t seem to be fixed with
      Microsoft Edge 41.16299.248.0 as well.

      Which release will it be fixed with? 17025?

    • When will this get merged in stable release ?
      Right now it is not available in 16.16299 version . Will this be available under 17.17024 ?

      Two versions I see on edge page
      Stable : MSEdge on Win10 (x64) Stable (16.16299)
      Preview : MSEdge on Win10 (x64) Preview (17.17074)

    • This will be in the Spring creators update or any of the most recent insider flights (17120 should have it). https://blogs.windows.com/windowsexperience/2018/03/13/announcing-windows-10-insider-preview-build-17120-for-fast/

    You need to sign in to your Microsoft account to add a comment.

    Sign in