Bypass Android Hybrid Application splash screen and other startup activies

Hi,
I want to bypass the splash screen and other activities and jump to the Main Activity of the Android app.
How to do that ?

Thank you.

Do not give name of these activity as launchable activity try to give activity name from where u want to start as launchable activity in capabilities. This may throw error if activity u give is not a launchable

You can click skip button on these activities if present any using code

else u have to wait for them to disappear

Usually there is no method to bypass them, for alerts we have a cap autoAcceptAlerts if we set it all system related alerts are auto accepted by appium.

1 Like

Yes. I gave the Main Activity always. But the thing is I want to get the Page Source of the Main Activity. But when splash screens and custom alerts popped up, then appium java client try to get the page source from splash screen or popups. Do I need Thread.sleep(milliseconds) to wait for them to disappear ?

@amitjaincoer191 to eliminate ALL permissions alerts just add to driver start:

capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, "true");

all other alerts you should cover in code.

you can try try using mine function for alerts - but! if you have custom alert it will fail.

    public boolean acceptAlert(int waitTimeInSec) {
        System.out.println("   wait to dismiss dialog");
        WebDriverWait wait = new WebDriverWait(driver, waitTimeInSec);
        try {
            wait.until(ExpectedConditions.alertIsPresent());
            driver.switchTo().alert().accept();
            return true;
        } catch (Exception e) {
            System.err.println("   no alert visible after "+waitTimeInSec+" sec.");
            return false;
        }
    }
1 Like

hi Aleksei

when I used this code it will give error.
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information). why is it hapenning ?

Thank you.

@Omesh_Dhanushka pls add more logs.

@Aleksei here are the logs
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: β€˜3.6.0’, revision: β€˜6fbf3ec767’, time: β€˜2017-09-27T15:28:36.4Z’
System info: host: β€˜OMESH’, ip: β€˜10.64.128.44’, os.name: β€˜Windows 10’, os.arch: β€˜amd64’, os.version: β€˜10.0’, java.version: β€˜1.8.0_144’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.gtnexus.appxlabs.epod, deviceScreenSize=1080x1920, networkConnectionEnabled=true, orientation=PORTRAIT, noReset=false, warnings={}, appiumVersion=1.7.2, databaseEnabled=false, deviceName=emulator-5554, avd=Nexus_5X_API_27, platform=LINUX, deviceUDID=emulator-5554, appActivity=com.gtnexus.appxlabs.epod.MainActivity, desired={appActivity=com.gtnexus.appxlabs.epod.MainActivity, appPackage=com.gtnexus.appxlabs.epod, orientation=PORTRAIT, noReset=false, appiumVersion=1.7.2, autoGrantPermissions=true, browserName=, platformName=android, deviceName=emulator-5554, avd=Nexus_5X_API_27}, platformVersion=8.1.0, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, autoGrantPermissions=true, browserName=, javascriptEnabled=true, deviceModel=Android SDK built for x86, deviceManufacturer=Google, platformName=LINUX}]
Session ID: cdc62596-adb9-4815-8b6f-07f9caa21476
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:986)
at org.openqa.selenium.support.ui.ExpectedConditions$28.apply(ExpectedConditions.java:808)
at org.openqa.selenium.support.ui.ExpectedConditions$28.apply(ExpectedConditions.java:804)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
at com.gtnexus.testautomation.runtime.starter.MobileBotController.acceptAlert(MobileBotController.java:130)
at com.gtnexus.testautomation.runtime.starter.MobileBotController.startupEmulatorAndLoadMainActivity(MobileBotController.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748)

@Omesh_Dhanushka ok then you need to write your own alert accept method for your custom app alerts

@Aleksei - Can you confirm that the method to accept alerts you provided will work only for webview apps and cannot be used in native context for that we need custom alert method?

@amitjaincoer191 i did not test mine method with webviews. only with native app.

@Omesh_Dhanushka maybe you did not import:

import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

?