Issue while inspecting hybrid app. Not able to find required selectors - hybrid-mobile-app

I am automating a hybrid app using Appium, using real mobile device. So my code is written as below:
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability(CapabilityType.BROWSER_NAME,"Chrome");
capabilities.setCapability("deviceName", "77377f50");
capabilities.setCapability("platformVersion", "9");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("automationName", "uiautomator2");
capabilities.setCapability("autoWebview", "true");
capabilities.setCapability("appium:chromeOptions", ImmutableMap.of("w3c", false));
capabilities.setCapability("appPackage", "com.englishbolo.android.alpha");
capabilities.setCapability("appActivity", "com.englishbolo.android.ui.EnglishBoloSplashScreen filter 36b63470");
capabilities.setCapability(MobileCapabilityType.FULL_RESET,false);
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Set <String> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println("Available Context:"+contextName);
}
driver.context((String) contextNames.toArray()[1]);
driver.findElement(By.xpath("//android.view.View[contains(#resource-id,'en_US')]")).click();
driver.findElement(By.xpath("//android.widget.Button[contains(#resource-id,'OK')]")).click();
driver.findElement(By.xpath("//android.view.View[#text='SIGNUP FREE']")).click();
driver.findElementByClassName("android.widget.Spinner").click();
driver.findElementByXPath("//android.widget.EditText[contains(#resource-id,'userFullName')]").sendKeys("ebuat");
driver.findElementByXPath("//android.view.View[#text='Sri Lanka+94']").click();
driver.findElementByXPath("//android.widget.EditText[contains(#resource-id,'userPhone')]").sendKeys("744693540");
driver.findElementByXPath("//android.widget.EditText[contains(#resource-id,'userPassword')]").sendKeys("1234");
driver.findElementByXPath("//android.widget.EditText[contains(#resource-id,'userMailId')]").sendKeys("ebuatuser_nov18#sharklasers.com");
driver.hideKeyboard();
driver.findElementByXPath("//android.widget.Button[#text='SUBMIT']").click();
driver.findElementByXPath("//android.widget.Button[#text='START NOW']").click();
After this last click action i need to click on radio buttons but after inspecting in appium desktop, only class as a locator is present.
For all radio button class android.view.View is the locator present.
I have used xpath using class name, text * resource-id present. If only classname is present So how can I form xpath to click on radio buttons?
Set <String> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println("Available Context:"+contextName);
}
driver.context((String) contextNames.toArray()[1]);
Also I have written method getContextHandles to set view to WebView.
Error observed after writing this method:
INFO: HTTP Status: '400' -> incorrect JSON status mapping for 'unknown error' (500 expected)
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: No such context found.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'englishhelper-MS-7A15', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-52-generic', java.version: '12.0.1'
Driver info: driver.version: AndroidDriver
remote stacktrace: NoSuchContextError: No such context found.
at AndroidUiautomator2Driver.setContext (/tmp/.mount_AppiumZrt5AD/resources/app/node_modules/appium/node_modules/appium-android-driver/lib/commands/context.js:57:11)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'englishhelper-MS-7A15', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-52-generic', java.version: '12.0.1'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
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:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:95)
at appium_new.AppiumSignup.main(AppiumSignup.java:62)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186)
... 13 more
Caused by: org.openqa.selenium.WebDriverException: No such context found.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'englishhelper-MS-7A15', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-52-generic', java.version: '12.0.1'
Driver info: driver.version: AndroidDriver
remote stacktrace: NoSuchContextError: No such context found.
at AndroidUiautomator2Driver.setContext (/tmp/.mount_AppiumZrt5AD/resources/app/node_modules/appium/node_modules/appium-android-driver/lib/commands/context.js:57:11)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
... 18 more
Can you please help me with the solutions you may know.

Related

Error: io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0

2022-06-07 09:14:19.862 DEBUG testcase.TEST - 8: switchToWindow(findWindowsObject("Object Repository/mainWindow/mainFrame"))
lut 20, 2020 9:14:20 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: OSS
2020-02-20 09:14:20.033 DEBUG testcase.TEST - 9: click(findWindowsObject("Object Repository/mainWindow/menuItem", ["itemName":"KOI"]))
2020-02-20 09:14:21.419 ERROR c.k.k.core.keyword.internal.KeywordMain - ❌ An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'APS00076262-MB', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities {appTopLevelWindow: 808ba, javascriptEnabled: true, platform: WINDOWS, platformName: WINDOWS}
Session ID: B4334F10-B953-4EF6-B814-E43A3B191EFA
*** Element info: {Using=xpath, value=//MenuItem[#Name="${itemName}"]} (Root cause: org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'APS00076262-MB', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities {appTopLevelWindow: 808ba, javascriptEnabled: true, platform: WINDOWS, platformName: WINDOWS}
Session ID: B4334F10-B953-4EF6-B814-E43A3B191EFA
*** Element info: {Using=xpath, value=//MenuItem[#Name="${itemName}"]}

Not able to interact with application using any of the locator - throwing me 'Locator Strategy 'name' is not supported for this session'

Testing an Android app and not able interact with app
Tried with ID, xpath and other locator but still display same error message.
#AndroidFindBy(xpath = "//android.widget.Button[#text='English']")
public WebElement language;
#AndroidFindBy(xpath="//android.widget.Button[#text='GET STARTED']")
public WebElement start;
The error I am getting is:
FAILED: login org.openqa.selenium.InvalidSelectorException: Locator Strategy 'name' is not supported for this session For documentation on this error, please visit: seleniumhq.org/exceptions/invalid_selector_exception.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'nsubramani-mbp-1', ip: 'fe80:0:0:0:10b4:b83f:ee48:38b2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_202' Driver info: io.appium.java_client.android.AndroidDriver

HttpHostConnectException when trying to connect to Jenkins Selenium Grid Plugin

I created a Jenkins Selenium Grid using the Selenium Plugin and have registered my nodes.
Now, when I am trying to start the tests on the grid using my machine, I get the following error
Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'sample', ip: 'sample', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_74'
Driver info: driver.version: SeleniumDriver
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'sample', ip: 'sample', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_74'
Driver info: driver.version: SeleniumDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:667)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:255)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:138)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:175)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to CDEA.emea.abc.corp:4444 [CDEA.emea.abc.corp/172.30.217.175] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:337)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646)
... 15 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 30 more
I can ping the Grid URL (CDEA.emea.abc.corp) and get a response from the same machine. So, I assume I do not need a Proxy? What could be wrong?
I have configured the Nodes and Master through the Plugin itself, they are configured with Chromedriver plugin and are online.
This is how I initiate the connection,
driver = createRemoteDriver(remoteUrl, caps, checkForProxy, settings.getDriverSettings());
where RemoteUrl = http://CDEA.emea.abc.corp:4444/wd/hub
caps = Capabilities [{acceptInsecureCerts=true, browserName=chrome, chromeOptions=org.openqa.selenium.chrome.ChromeOptions#3d8a4416, version=, platform=ANY}]
checkforProxy = false

Dropdown not working with safariDriver on Safari 10

I am getting below error while accessing dropdown using Safari 10 mac sierra with apple safariDriver:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 17 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'nb-rohitsharma.vserv-it.com', ip: '192.168.1.69', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.4', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, databaseEnabled=true, handlesAlerts=true, version=12603.1.30.0.34, cleanSession=true, platform=MAC, nativeEvents=true, locationContextEnabled=false, webStorageEnabled=true, browserName=safari, javascriptEnabled=true, platformName=macOS, cssSelectorsEnabled=true}]
Session ID: A404BC72-307B-4B5B-802A-EF6021A65544
*** Element info: {Using=xpath, value=//select[#id='programIdSelect']}
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:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:473)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
at com.efollett.ims.CustomLibrary.UserLibrary.selectDDCSdetails_IMS(UserLibrary.java:1369)
at com.efollett.ims.ExistingUser.TS_Reg_IMS_002.EB_NonRental_Ship_Credit(TS_Reg_IMS_002.java:78)
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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
This is a known issue in WebKit. The workaround for now is to use JavaScript to modify the selected elements. You can track the fix here: https://bugs.webkit.org/show_bug.cgi?id=174710

Problems starting iOS driver

I am having difficulty with executing a test with my driver.
1) I start my server with the following (grid does not start as I am getting kicked out… for another thread)
java -jar ios-server-standalone-0.6.6-SNAPSHOT.jar -port 1111
2) I launch a test from the respective directory
3) The logs dump the following:
The server cannot run Capabilities [{platform=MAC, cssSelectorsEnabled=false, CFBundleIdentifier=com.apple.mobilesafari, javascriptEnabled=true, nativeEvents=false, locale=en_GB, CFBundleName=Safari, variation=Retina4, device=iphone, rotatable=false, takesScreenshot=false, sdkVersion=7.1, version=}] at the moment.org.uiautomation.ios.application.APPIOSApplication cannot be cast to org.uiautomation.ios.application.IPAApplication
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '(hidden for privacy)', ip: '(hidden for privacy)', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_67'
Driver info: driver.version: unknown
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '(hidden for privacy)', ip: '(hidden for privacy)', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.7.0_67'
Driver info: driver.version: unknown (org.openqa.selenium.SessionNotCreatedException) (Selenium::WebDriver::Error::WebDriverError)
[remote server] org.uiautomation.ios.command.uiautomation.NewSessionNHandler(NewSessionNHandler.java):100:in `safeStart'
What is the root cause?
Having had the exact same issue, you could try using
capabilities.setCapability("simulator", true);
This got me past this issue at least (and into another one).

Resources