Hello,
I’m doing automation on real android device with Appium on Mac with Ruby.
I see that’s it’s possible to go in a webview in an app but I don’t sucess to do it.
I’ve read on appium website that I have to do :
Given(/^I switch to webview$/) do
webview = @driver.contexts.last @driver.switch_to.context(webview)
end
Given(/^I switch out of webview$/) do @driver.switch_to(@driver.contexts.first)
end
But when I try that, I have “undefined method `contexts’ for Selenium::WebDriver::Driver:0x007fefc17d09c0 (NoMethodError)”
I have the last gem of appium_lib and selenium-webdriver.
I’ve put this in my env.rb
require ‘rubygems’
require ‘watir-webdriver’
require ‘rspec’
require ‘page-object’
require ‘page-object/page_factory’
require ‘require_relative’
require ‘yaml’
require ‘selenium-webdriver’
require ‘appium_lib’
The “classic” fonctions of watir selenium are working (like find_element, click…)
So why “contexts” not ?
Maybe I’m missing something.
I decalre: capabilities =
{
‘appPackage’=> 'myapp.demo,
‘appActivity’=> ‘.MainActivity’,
‘platformName’ => ‘Android’,
‘deviceName’ => ‘Galaxy S4’,
}
server_url = ‘http://127.0.0.1:4723/wd/hub’ @driver = Selenium::WebDriver.for(:remote, desired_capabilities: capabilities, url: server_url) @browser = Watir::Browser.new @driver @browser.driver.manage.timeouts.implicit_wait = 30
Any help on this ?
Please I really need to get it work.
Am I missing something in my code ? It fails at “webview = @driver.contexts.last” with ““contexts” function unknow.”
Thanks a lot !
Please internet guys, I’m on it from days. I don’t know how to use the appium_lib gem…
Cna you get why the contexts function in not recognized ? Thanks a lot
I’ve tried a lot of things like @driver = Selenium::WebDriver.for(:remote, desired_capabilities: capabilities, url: server_url) @browser = Watir::Browser.new @driver
But I always have an error.
I’ve tried too android testing on this page : https://www.omniref.com/ruby/gems/appium_lib/0.24.1
But not ok too.
I’m really stuck at this.
How to get into the webview on a app ? If someone can modify my code to do that it will be grate, thanks.
Thanks for the link, I’ve read all the chapters but I still don’t get it.
I’m not using saucelabs, only real device.
And I still don’t get how to declare the appium browser/driver (I don’t even know what should it be). Only Sellenium webdriver and Watir browser is recognized.
So I’m not able to get into the webview.
Can you tell me what to change in mode to make it ok ?
Thanks a lot
My code is: