No targets found, when switching from app to browser on iOS
See original GitHub issueThe problem
Sometimes you need to automate the following flow
- login to a native app
- after login you need to pay something and a link in the app opens a browser
- the browser needs to be used to pay
- after payment the browser is opening the app again
- the payment in the app is processed
This is currently failing at step 3 with the following error Encountered internal error running command: Error: No targets found, unable to communicate with device
Environment
- Appium version (or git revision) that exhibits the issue:
1.14.0
- ~Last Appium version that did not exhibit the issue (if applicable):~
- Desktop OS/version used to run Appium: OSX Mojave
- Node.js version (unless using Appium.app|exe):
v10.15.2
- Npm or Yarn package manager: npm
- Mobile platform/version under test: iOS 12.2
- Real device or emulator/simulator: sim
- Appium CLI or Appium.app|exe: cli
Link to Appium logs
The logs can be found here
Code To Reproduce Issue [ Good To Have ]
I’m using WebdriverIO and the Sauce Labs sample app to execute the test, the test executes the following steps:
// config
config.capabilities = [
{
// The defaults you need to have in your config
deviceName: 'iPhone X',
platformName: 'iOS',
platformVersion: '12.2',
orientation: 'PORTRAIT',
// The path to the app, see https://github.com/saucelabs/sample-app-mobile/releases
app: join(process.cwd(), './apps/iOS.Simulator.SauceLabs.Mobile.Sample.app.2.1.0.app.zip'),
// Read the reset strategies very well, they differ per platform, see
// http://appium.io/docs/en/writing-running-appium/other/reset-strategies/
noReset: true,
newCommandTimeout: 240,
maxInstances: 1,
fullContextList: true,
},
];
describe('Appium', () => {
it('should be able to work with the browser that is opened with the app', () => {
// Login to the app and verify that it succeeded
LoginScreen.waitForIsShown();
LoginScreen.signIn(LOGIN_USERS.STANDARD);
InventoryListScreen.waitForIsShown();
expect(InventoryListScreen.isShown()).toEqual(true);
// Open the menu and click on the about screen
Menu.open();
Menu.openAbout();
let webviewID = {};
driver.waitUntil(() => {
const contexts = Context.getCurrentContexts();
webviewID = contexts
.filter(context => {
console.log('filter context = ', context)
return !context.id.includes('NATIVE_APP')
})
.find(context => {
console.log('some context = ', context)
return context.url.includes('https://saucelabs.com/')
});
return webviewID || false;
}, DEFAULT_TIMEOUT);
driver.switchContext(webviewID.id);
expect(browser.getTitle()).toEqual('Cross Browser Testing, Selenium Testing, Mobile Testing | Sauce Labs');
})
})
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
I can't log in to Target app using iphone… - Apple Community
If so, try turning off VPN. Go to Settings/Safari and tap Clear History and Website Data. That will clear the cache.
Read more >Mobile & app support - Target Help
On your iOS device, go to Settings, then Wi-Fi. Turn on your Wi-Fi connection if it's not already on. Browse the list of...
Read more >Possible to open iPhone Safari and target a specific window?
What I noticed about Safari is that it won't open another tab if the page you are opening with openURL: is/was already open...
Read more >Debugging Guide for Apps in iOS Safari and Android Chrome
The app preview may not automatically appear when you open Chrome Developer Tools due to a minor bug. To make it appear, click...
Read more >iOS/iPadOS app protection policy settings - Microsoft Intune
Specify which iOS/iPadOS Universal Links should open in the specified managed application instead of the protected browser specified by the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wswebcreation Can you try the latest beta of Appium, and add the
includeSafariInWebviews
capability (set totrue
) to your desired caps for the test?Retested this with Appium
1.15.0
-stable and it works like a charm, thanks for this!!