loc.last) .shadow_root .text_fi" /> loc.last) .shadow_root .text_fi" /> loc.last) .shadow_root .text_fi"/>

Hover method is not working when shadow root is used

69 Views Asked by At

I located the element using shadowroot like shown below

loc = locator.split("=")
[email protected](loc.first => loc.last)
        .shadow_root
        .text_field

I am currently able to click on the element without any issues, however, upon attempting to hover over it, the following error occurs

"undefined method `driver' for #<Watir::ShadowRoot:0x0806d828 @query_scope=#<Watir::HTMLElement: located: true; {\"id\"=>\"user.name\"}>, @shadow_root=#<Selenium::WebDriver::ShadowRoot:0x..fd1bb37b8 id=\"8870eb8d-d11c-4a03-9ae9-1d6780e109a2\">>\n\n      @query_scope.driver\n                  ^^^^^^^"
1

There are 1 best solutions below

4
Justin Ko On BEST ANSWER

From a quick test, looks like we just need to define the method and everything will work.

Can you try monkey-patching your Watir?

module Watir
  class ShadowRoot
    def driver
      browser.driver
    end
  end
end

If that works, we can get it incorporated into the actual code base.