Having trouble using Capybara and Selenium to find an svg tag on a page

后端 未结 2 1108
难免孤独
难免孤独 2021-01-06 07:05

I had a test case like this:

  scenario \"there should be an SVG tag\" do
    ...
    page.find(\"svg\")
  end

For some reason, Capybara co

2条回答
  •  不知归路
    2021-01-06 07:50

    It turns out this is an issue with Firefox's built in xpath evaluator.

    Using FireBug, I was able to verify that the call that Selenium uses:

    document.evaluate("//svg", document, null, 9, null).singleNodeValue
    

    doesn't return any elements, whereas

    document.evaluate("//div", document, null, 9, null).singleNodeValue
    

    returns the first div on the page.

    There may be some namespacing issues that could get FireFox to return svg elements. For now I've just looked for elements with my svg xmlns attribute.

提交回复
热议问题