Search code examples
rubywindowsselenium-webdriverwinappdriver

right click on application in system tray using winapp driver


I am trying to automate a right click on antivirus icon in the system tray but been out of luck with it. Is there a different way to implement it.


the code that i am trying is given below


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()

I see below error when i try to run this method

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'


Solution

  • just an issue with a element driver.action.context_click(element).perform is the correct syntax as long as the element is identified correctly