In order to get an Android toast, you need to upgrade selenium to 3.4.0 and Appium 5.0.0-beta9 to the latest version and append a line of code before the startup code:
Capabilities.setcapability (Mobilecapabilitytype.automation_name, Automationname.android_uiautomator2);
Getting toast needs to be at the Android API level above 20 and 20 to work correctly.
After adding the necessary statements, execute the Automation code, error: The Desiredcapabilities object is not valid for the following reason (s): DeviceName can ' t is blank
Org.openqa.selenium.sessionnotcreatedexception:a new session could not be created. Details:the Desiredcapabilities object is not valid for the following reason (s): DeviceName can ' t is blank, (warning:th E server did not provide any stacktrace information)
Command duration or timeout:0 milliseconds
Build info:version: ' 3.3.0 ', Revision: ' B526bd5b41 ', Time: ' 2017-03-07 19:26:04 +0000 '
System info:host: ' windows7 ', IP: ' 192.168.59.1 ', Os.name: ' Windows 7 ', Os.arch: ' x86 ', os.version: ' 6.1 ', java.version: ' 1.8.0_45 '
Driver Info:driver.version:AndroidDriver
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:422)
At Org.openqa.selenium.remote.ErrorHandler.createThrowable (errorhandler.java:216)
At org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed (errorhandler.java:168)
At Io.appium.java_client.remote.AppiumProtocolHandShake.createSession (appiumprotocolhandshake.java:161)
At Io.appium.java_client.remote.appiumprotocolhandshake.lambda$2 (appiumprotocolhandshake.java:88)
At io.appium.java_client.remote.appiumprotocolhandshake$ $Lambda $5/23545302.get (Unknown Source)
At Java.util.Optional.orElseGet (optional.java:267)
At Io.appium.java_client.remote.appiumprotocolhandshake.lambda$0 (appiumprotocolhandshake.java:83)
At io.appium.java_client.remote.appiumprotocolhandshake$ $Lambda $4/10853795.get (Unknown Source)
At Java.util.Optional.orElseGet (optional.java:267)
At Io.appium.java_client.remote.AppiumProtocolHandShake.createSession (appiumprotocolhandshake.java:78)
At Io.appium.java_client.remote.AppiumCommandExecutor.doExecute (appiumcommandexecutor.java:111)
At Io.appium.java_client.remote.AppiumCommandExecutor.execute (appiumcommandexecutor.java:162)
At Org.openqa.selenium.remote.RemoteWebDriver.execute (remotewebdriver.java:604)
At Io.appium.java_client. Defaultgenericmobiledriver.execute (defaultgenericmobiledriver.java:42)
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.startSession (remotewebdriver.java:244)
At Org.openqa.selenium.remote.RemoteWebDriver. (remotewebdriver.java:131)
At Org.openqa.selenium.remote.RemoteWebDriver. (remotewebdriver.java:144)
At Io.appium.java_client. Defaultgenericmobiledriver. (defaultgenericmobiledriver.java:38)
At Io.appium.java_client. Appiumdriver. (appiumdriver.java:88)
At Io.appium.java_client. Appiumdriver. (appiumdriver.java:112)
At Io.appium.java_client.android.AndroidDriver. (androiddriver.java:73)
Cause of the problem, Appium server side upgrade to 1.6.5, Appium the sub-module under the installation directory \appium\node_modules\appium-uiautomator2-driver folder Uiautomator2 below 2 Essential Android APK files:
appium-uiautomator2-server-debug-androidtest.apk
appium-uiautomator2-server-v0.1.5.apk
This is the time to execute the command in the Appium installation directory: NPM install Appium-uiautomator2-driver installation Appium-uiautomator2-driver
After the installation is complete, there should be 2 apk files in the Npm\node_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2 directory
Appium +uiautomator2 encounters devicename can ' t be blank prompt resolution