Making a short summary.
-
For Android, I can identify the elements through the ID (I contacted the DEVs to enter the ID in the fields) … Unfortunately I did not succeed in searching for class, class_name, xpath etc … just by ID.
-
It worked in env.rb by configuring as follows for Android:
NOTE: the most important is: autoWebview: true.
Before do
def caps
{
caps: {
browserName: ‘’, # Deve usar uma string vazia se estiver automatizando um aplicativo
deviceName: ‘0029179798’, # ‘0029179798’ Motorola Moto Z Play
platformName: ‘Android’,
app: (File.join(File.dirname(FILE), ‘build/apk/baseline09_new.apk’)),
appPackage: ‘io.ionic.starter’,
appActivity: ‘io.ionic.starter.MainActivity’,
newCommandTimeout: 1800,
platformVersion: ‘8.0.0’,
autoWebview: true,
androidScreenshotPath: ‘results/screenshots’,
nativeWebScreenshot: true,
automationName: ‘uiautomator2’,
chromedriverExecutable: (File.join(File.dirname(FILE), ‘drivers/chromedriver.exe’))
},
appium_lib: { server_url:SERVER_URL, port:PORT }
}
end
end
- I have not tried it on IOS yet - I’m thinking I’ll have problems … but keep this post open for us to discuss.
If anyone knows of any GEM that helps, or something related to the protractor with ruby, or method or GEM that helps identify the other elements of IONIC.
also search hints for xpath element, class with ruby + appium.
- Below is some more information on going to the NATIVE context and WEBVIEW Context with ruby.
in the hooks.rb file, where I do the encoding of the screenshot for each scenario I do the following
Before do
@driver = Appium::Driver.new(caps, true)
Appium.promote_appium_methods Object
@driver.start_driver
#Espera IMPLÍCITA - Define um tempo limite de espera para todos os elementos
@driver.set_wait(5)
#contexts = @driver.available_contexts
#puts contexts
# @driver.set_context('WEBVIEW_io.ionic.starter')
# Contextos disponívels: ["NATIVE_APP", "WEBVIEW_io.ionic.starter", "WEBVIEW_chrome"]
# Os contextos WEBVIEW_io.ionic.starter e
# WEBVIEW_chrome são similares e estão setados no env.rb = autoWebview: true
end
Notice that the context switch is commented out, this is because when I put it in env.rb that “autowebview” = true, I’m already saying that I’m going to work with IONIC + Angular in the WEBVIEW context.
In some situations, I need to go back to the NATIVE context … for example, to make clicks on the screen in some coordinate, I need to go to the native context.
I do as follows.
In a method on my page.
def limpar_campo
# CLICAR NO BOTÃO CONFIRMAR (Coordenadas do MOTO Z Play - Android)
@driver.set_context('NATIVE_APP')
1.times{ Appium::TouchAction.new.tap( x: 945, y:1545, count: 1).release.perform }
@driver.set_context('WEBVIEW_io.ionic.starter')
end
So when I call the cleanup_field method, I click on the Android X to delete the contents of a certain field. For example, to delete the word “Apple” I need to clear the method field 5 times, ie, press 5 times in the Android X to delete the content.
Well, that’s what I know for now … I hope to help them and I hope they help me when I go to IOS.
Hugs
Isaias Silva - Tester Enginner - isaiasilva.info@gmail.com