Hover方法在使用影子根时不起作用。

huangapple go评论86阅读模式
英文:

Hover method is not working when shadow root is used

问题

I located the element using shadowroot like shown below:

loc = locator.split("=")
element = @browser.element(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">>
@query_scope.driver
              ^^^^^^^"
英文:

I located the element using shadowroot like shown below

loc = locator.split(&quot;=&quot;)
element=@browser.element(loc.first =&gt; 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

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

答案1

得分: 0

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.

英文:

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.

huangapple
  • 本文由 发表于 2023年4月13日 17:43:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76003976.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定