0

I have tried using below capabilities

{
      maxInstances: 1,
      browserName: '',
      appiumVersion: '1.18.2',
      platformName: 'android',
      platformVersion: '10.0',
      deviceName: 'device',
      webviewConnectTimeout: '90000',
      chromeOptions: {args: ['--windowTypes=webview']},
      safariLogAllCommunication: true,
      enableWebviewDetailsCollection: true,
      ensureWebviewsHavePages: true,
      showChromedriverLog: true,
      app: './android/app/build/outputs/apk/',
      noReset: true,
      autoWebview: true,
}

but still not able to fetch the webview url. Below is the snippet of my code

let contexts = driver.getContexts();
console.log(contexts);
driver.switchContext('WEBVIEW_be.belgacom.hello');
console.log(driver.getPageSource());
console.log(driver.getUrl());

2 Answers2

0

By meaning WebView if you want to open a web application/website in chrome app in android, these are the mandatory capabilities:

{'platformName': 'Android,'udid': YOUR DEVICE UDID, 
'appActivity': 'com.google.android.apps.chrome.Main', 
'appPackage': 'com.android.chrome',
'chromedriverExecutable': PATH OF CHROME DRIVER, 
'deviceName': ANY NAME,'chromeOptions': {'w3c': False},'autoGrantPermissions': True}

You should switch to WEB_VIEW in case of doing action on the chrome mobile.

The syntax is in Python:

driver.switch_to.context['NATIVE_APP]   #appium chrome driver
driver.switch_to.context['WEB_VIEW_chrome']    # selenium chrome driver

Here is my full answer about context switching: https://stackoverflow.com/a/62284044/7302505

Answer to the comment:

from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--incognito")
  • Thanks for answering, but how can i add chrome options in capabilities as to the way the syntax should be? as i am giving it this way chromeOptions: {args: ['--w3c=false'] – Dipika Mishra Oct 29 '21 at 12:28
  • I've edited the answer and added the answer to this question, If your problem is resolved please check the tick :) – Mohammad Monfared Nov 01 '21 at 07:00
0

for Java:

ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("w3c",false); 
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 22 '23 at 04:52