We are attempting to run our tests for our Mobile app on BrowserStack through our Bitbucket pipeline, using Appium version 6.0.0 with the AndroidDriver, which inherits from RemoteWebDriver. We are currently passing the URL to BS with our capabilities (AndroidDriver(AppiumDriverLocalService service, org.openqa.selenium.Capabilities desiredCapabilities)), however the test suite always loses connection to the BrowserStack Hub about half way through.
I wanted to try to add a Factory in the Android Driver to increase the HTTP Timeout and see if that would help my case (AndroidDriver(AppiumDriverLocalService service, org.openqa.selenium.remote.http.HttpClient.Factory httpClientFactory, org.openqa.selenium.Capabilities desiredCapabilities)). The code as is runs fine when running from my local machine to BS but as soon as we run from Bitbucket or even Jenkins, then the network issues start to occur.
Does anyone have an example on how I would be able to achieve this?
Tried this one?
WebDriverWait wait = new WebDriverWait(driver, timeLimitInSeconds);
element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(“desired xpath”)));
Else you can explicitly wait for several seconds using thread.sleep()
Related
I have a sample app that uses Parse Server. I've been testing my app on both emulator and physical devices and I noticed that the response time is much slower on the physical device.
This one is from the emulator.
and this is one is from the physical device:
I've been scratching my head regarding this one. I've also posted it on the parse community platform and followed the advice there to manually monitor the server for every change I've made until I reach my prior server configuration. I overhauled the server from scratch. Do some load testing -> Deployed the server on a replica set -> load testing. Now, I'm in the process of doing some basic queries. I used ADB logcat to see what's happening on both device and saw these errors on the physical device and not on the emulator:
E[N rtchannel]_rt_mqtt_publish_callback(356)=>Failed to publish the request over MQTT. token:be925eea-407c-417d-96c9-3af5a7e83e48, category:mcd-sync-data-task-category, requestId:54138, error:Error Domain=mqtt Code=3008
E[S sync]_createResponseError(166)=>Network Response be925eea-407c-417d-96c9-3af5a7e83e48 contains sync error Error Domain=mqtt Code=3008 - Underlying error (null): Error Domain=mqtt Code=3008
This one also shows before pulling the payload.
W[S sync-state-machine]MCDSyncStateMachineScheduleDelayedRetry(173)=>skipping the new retry with longer delay
W[S sync]_scheduleNextCursorRetry(326)=>skipping delayed retry due to state machine state decision
The number of times these errors pop up is related to the number of queries executed. I did not put any configurations on the server which use MQTT. Any help is much appreciated.
I made test which close mobile app and after 2 seconds launch it.
self.welcome_page.confirm_continue()
self.driver.close_app()
sleep(2)
self.driver.launch_app()
sleep(1)
after than I get WebDriverException for every interaction with driver. (e.g. find_element, current_url, refresh ...)
On the screenshot and in the video I see that the app is in expected state and obviously launched successfully.
I am running tests against BrowserStack. with following BrowserCapabilities
[Android]
app=$APP_ID_ANDROID
AppfileName=$APP_NAME_ANDROID
AppCustomID=Corkscrew_andorid
autoAcceptAlerts=true
autoGrantPermissions=true
browserstack.debug=true
device=Samsung Galaxy Note 9
deviceName=Android Emulator
deviceOrientation=portrait
name=cs_test
os=android
os_version=8.1
no-reset=true
full-reset=false
autoWebview=true
response from Webdriver has old version of chromedriver.
'status': 100, 'value': {'message': 'chrome not reachable\n ...o: chromedriver=2.42.591071
appium logs: HERE
probably (I guess) the driver is not active anymore and new one was created by launching app. But how can I get the new driver?
I am getting the error "It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible"
also my Appium server gets killed autometically after this error in console.
Please help to resolve.
The error may occurs from various reason. You need to check your appium server log to know the exact cause. Beside that you can verify following.
Start your appium server in session-override option.
Make sure your appium server is running.
Make sure your are using correct url of appium server.
Confirm your device is properly connecting to the laptop. You can verify it by using adb devices command (for android). Make sure it is showing only one device.
Make sure your DesiredCapabilities are correct or all required desired capabilities are included.
Try re-starting the appium server.
I am a beginner in automation testing. I am trying to write common test project for my android and ios app. Both the apps on ios and android have almost same UI and flow. I want to know how can I instantiate Appium driver for based on the platform.
As of now, I am thinking to have a boolean variable isAndroid which I would have to manually change in the code before running the tests.Based on isAndroid I instantiate AppiumDriver to AndroidDriver or IOSDriver and elements will be located as per #AndroidFindby or #IOSFindBy
When I start Appium from the terminal, I mention the parameter platformName, is there a way to fetch that information in my code so that I do not have to manually change isAndroid variable and exactly same test code runs on both platforms.
Are you able to try one platform, catch the exception and then try the other?
try:
driver = webdriver.Remote('http://localhost:4723/wd/hub', ios_caps)
run_iOS_tests(driver)
except selenium.common.exceptions.WebDriverException:
driver = webdriver.Remote('http://localhost:4723/wd/hub', android_caps)
run_android_tests(driver)
Otherwise you'll need to use some external method to see what devices are connected (android, ios).
Since I'm working in a platform which works with many apps (rather than a single target app), I find the selection of a target app inefficient for my needs. I wondered if I could do something to avoid it.
I'd like to run freely, sending UI commands to iOS and Android real devices, including installing an app from another app (like Play Store, Apple Store, Test Flight, etc.)
Thanks for the help,
David.
The rule is: 1 Webdriver instance per application.
You can run Appium's server with no --app argument by making sure auto-launch is set to false, and not setting bundleId or app.
Then, in your client/test framework, you use several webdrivers, configured to use different desired capabilities, to tie it all together under a single test case/suite.
The solution:
You may have a test suite that sets desired_capabilities to launch the Safari app, then you install the app, then you quit the webdriver.
Then you change the desired_capabilities to point to the bundle_id of the new app, launch another webdriver instance, do your tests, quit the webdriver..
Then you change the desired_capabilities to point to (etc., etc.)
driver = webdriver.new(url, desired_capabilities)
// do some stuff
driver.quit()
desired_capabilities['app'] = 'company.app.com'
driver = webdriver.new(url, desired_capabilities)
// do some stuff
driver.quit()
desired_capabilities['app'] = '/path/to/application.app'
driver = webdriver.new(url, desired_capabilities)
// do some stuff
driver.quit()