I use this method to find a context and change it to webview:
Set<String> strcontext = null;
try{
strcontext = ((AndroidDriver) AppiumInit.getAppiumDriver()).getContextHandles();
System.out.println("Found contexts size: '" + strcontext.size() + "'");
for (String s :strcontext) {
System.out.println("Found context: '" + s + "'");
if (s.contains("WEBVIEW")) {
System.out.println("Switching context to: '" + s + "'");
((AndroidDriver) AppiumInit.getAppiumDriver()).context(s);
break;
}
}
} catch (Exception e){
e.printStackTrace();
}
and i got it:
Found contexts size: â2â
Found context: âNATIVE_APPâ
Found context: âWEBVIEW_com.dkveuroservice.mobileappkit.stagingâ
Switching context to: âWEBVIEW_com.dkveuroservice.mobileappkit.stagingâ
After that Im checking current context:
Current Context: WEBVIEW_com.dkveuroservice.mobileappkit.staging
Okay so with context everything is okay.
now Iâm checking the text of the title:
public String getFeedbackWebTitl() {
WebDriverWait wait = new WebDriverWait(AppiumInit.getAppiumDriver(), Duration.ofSeconds(10));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[@id=âtitleâ]")));
but i got this error - org.openqa.selenium.TimeoutException: Expected condition failed: waiting for presence of element located by: By.xpath: //span[@id=âtitleâ] (tried for 10 second(s) with 500 milliseconds interval)
Here is a link to the page - https://my-preprod.dkv-mobility.com/next-gen/feedback/general
i need to getText - What are your experiences with the DKV app?
yes you are right i can change the context but i have a problem with driver
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 117.0.5938.149 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
now i get new chromedriver from the website
and add it to my caps:
public void configureAndroidDriver() {
// Android Local configuration
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "autoTests");
// capabilities.setCapability(MobileCapabilityType.UDID, "1af75d19");
capabilities.setCapability(MobileCapabilityType.APP, "//Users//nifargo//Documents//DkvProject//web-app-framework-qa-ui-tests//src//test//resources//androidReleaseBuild.apk");
capabilities.setCapability("automationName", "UiAutomator2");
capabilities.setCapability("appPackage", "com.dkveuroservice.mobileappkit");
capabilities.setCapability("appActivity", "com.dkveuroservice.mobileappkit.MainActivity");
**capabilities.setCapability("chromedriverExecutable", "/Users/nifargo/Downloads/chromedriver_mac_arm64/chromedriver");**
capabilities.setCapability("showChromedriverLog", true);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 500);
String ipAddress = new Properties().getProperty("ipAddress");
after that I got this error:
io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 103.0.5060.71 with package name com.dkveuroservice.mobileappkit
but even with new 117 chrome driver version that I added to my caps I got this error:
io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 117
Current browser version is 103.0.5060.71 with package name com.dkveuroservice.mobileappkit