使用 winapp 驱动程序右键单击系统托盘中的应用程序

right click on application in system tray using winapp driver

我正在尝试自动右键单击系统托盘中的防病毒图标,但没有成功。有没有不同的实现方式。


下面给出了我正在尝试的代码


require 'selenium-webdriver'


def caps 
    {
        platformName: "WINDOWS", platform: "WINDOWS", deviceName: "mydevice", app: "Root"
    }
end



driver = Selenium::WebDriver.for(:remote, :url => "http://127.0.0.1:4723/", :desired_capabilities => caps )

driver.find_element(:name, 'Notification Chevron').click
sleep(5)
element = driver.find_element(:name, 'Avast')[0]
driver.action.context_click(element).perform()

当我尝试运行这个方法

时,我看到下面的错误

NoMethodError: undefined method []' for nil:NilClass C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.5.2/lib/selenium/webdriver/common/action_builder.rb:357:inperform'

只是一个元素的问题 driver.action.context_click(element).perform 是正确的语法,只要元素被正确识别