Android emulator tear down during tests run - selenium

guys!
I run my Android tests with Appium on Android emulator. Where I run my tests in sequence emulator sometimes tear down and remaining tests are ignored.
In Appium logs i see this error:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command 'C:\\Users\\Username\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s emulator-5554 shell settings delete global hidden_api_policy_pre_p_apps' exited with code 20'; Stderr: 'cmd: Can't find service: settings'; Code: '20'
Is there anybody face with such problem?

You are trying to run an adb-shell command which is not allowed.
Appium has some in-secure commands that normally it will not allow them to be used.
You can see the commands here: Appium Insecure Features
The adb-shell commands (to change the system settings) is one of them.
Follow the link to how to prevent appium checking this.
How to resolve:
At the beginning of test setup, run this commnad: appium --relaxed-security with command line. Then the appium let you using the insecure feautures during the test.
for example in pyhton you should run os.system(appium --relaxed-security (while having appium directory in the system environment variables path.

Related

Karate Performance testing : Getting build failure with error "Unrecognized VM option 'UseBiasedLocking'

I am trying to reuse Karate tests for performance testing with Gatling and Scala.
I have configured everything as described in documentation. But then when I run the mvn command I am getting error "Unrecognized VM option 'UseBiasedLocking' Error: Could not create the Java Virtual Machine."
mvn command used to run tests: mvn test-compile gatling:test
Tried with looking at Env path variables and running the mvn command with different options. But still getting same error
Failed to execute goal io.gatling:gatling-maven-plugin:4.1.5:test (default-cli) on project PerformanceTesting: Gatling failed.: Process exited with an error: 1 (Exit value: 1)
Below is the POM file
Scala File
The issue is resolved after upgrading the gatling.plugin.version to 4.2.7 as my Java version 19 is not supporting old gatling plugin.
Below article helped to resolve
Unrecognized VM option 'UseBiasedLocking' Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit

IntelliJ Python Debugging with Blaze

I'm currently trying to transition a project to Bazel, but I'm running into problems running the debugger for Python in IntelliJ. I have the current version of the Bazel plugin (v2019.06.17.0.1), and am using the current Bazel version (0.28.0). When I attempt to run a test in debug, I see
/usr/local/bin/python3.6 "/path/redacted" --multiproc --qt-support=auto --client 127.0.0.1 --port 53571 --file /path/also/redacted
pydev debugger: process 24526 is connecting
Connected to pydev debugger (build #.#.#.#)
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)
Has anyone found a good solution to this problem?

How can i get the result of a test (fail/pass) written in to a variable/file when testing with Detox on TravisCI

Im building my React Native app with TravisCI and using Detox to run E2E on the version.
The Detox test results are printed to the travis console but i need to know fail or pass in an env var so i could act on it.
The test command is:
detox test --configuration ios.sim.debug
So i've tried:
export SANITY_RES=$(detox test --configuration ios.sim.debug)
but echo $SANITY_RES only contains:
configuration="ios.sim.debug" artifactsLocation="artifacts/ios.sim.debug.2018-12-25 14-42-58Z" node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)$' detox[80481] INFO: [DetoxServer.js] server listening on localhost:51067...*
and not the final result.
Any other way i could get them ?
Detox allows you the ability to write logs of your builds. See for more details https://github.com/wix/Detox/blob/master/docs/APIRef.Artifacts.md
If you add —record-logs all as a flag to your detox test it will save all the logs of the build, change it to —record-logs failing if you only want logs of failing tests.
You can even specify where the logs will be stored.

Appium crashes giving the error "Error getting source, can't continue finding element by XPath"

My appium version is 1.4.13. Xcode version is 7, iOS simulator version is 8.4.
Appium server crashes while trying to execute a command.
The same test used to work perfectly fine. Not sure why it is not working now.
I have also added the following command in my capabilities.
capabilities.setCapability("newCommandTimeout" , 60);
Appium log is pasted here.
info: [IOS_SYSLOG_ROW ] Jan 13 16:17:37 clones-MacBook-Pro-6.local DTMobileIS[7664]: Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [debug] Cleaning sim data files
info: node-simctl: Executing: xcrun with args: simctl erase 3C31DBE5-A0FD-4C5A-BAEC-C02DF76BFB36 and timeout: 2000
error: Error getting source, can't continue finding element by XPath
info: [debug] Cleaning app data files
warn: Applications directory /Users/Bindu/Library/Developer/CoreSimulator/Devices/3C31DBE5-A0FD-4C5A-BAEC-C02DF76BFB36/data/Containers/Data/Application doesn't exist. Have you run this simulator before?
warn: Applications directory /Users/Bindu/Library/Developer/CoreSimulator/Devices/3C31DBE5-A0FD-4C5A-BAEC-C02DF76BFB36/data/Containers/Bundle/Application doesn't exist. Have you run this simulator before?
info: Couldn't find app directories to delete. Probably it's not installed
info: [debug] We were in the middle of processing a command when instruments died; responding with a generic error
info: [debug] Cleaning up appium session
info: [debug] Condition unmet after 2355ms. Timing out.
info: [debug] Responding to client with error: {"status":13,"value":{"message":"Instruments died while responding to command, please check appium logs","name":"UnknownError","origValue":"Instruments died while responding to command, please check appium logs"},"sessionId":null}
info: <-- POST /wd/hub/session/07d24536-708f-4515-af69-a35d5695119e/element 500 2356.834 ms
Here is the code for running my tests:
public void completeSignUpForm() throws InterruptedException {
elementUtils.sendValueToElement(FIRSTNAME, "TestName");
elementUtils.sendValueToElement(LASTNAME, "TestSurname");
elementUtils.sendValueToElement(PASSWORD, "Drayson123");
elementUtils.clickElementByXpath(AGE);
elementUtils.enterDataIntoPickerWheel(AGE_PICKER_WHEEL, "26-35", 0);
elementUtils.clickElementByXpath(PICKER_WHEEL_DONE_BUTTON);
elementUtils.clickElementByXpath(GENDER);
elementUtils.enterDataIntoPickerWheel(GENDER_PICKER_WHEEL, "Female", 0);
elementUtils.clickElementByXpath(PICKER_WHEEL_DONE_BUTTON);
elementUtils.clickElementByXpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[9]/UIASwitch[1]");
Thread.sleep(3000);
elementUtils.clickElementByXpath(JOIN_US_BUTTON);
}
Support code for the methods from ElementUtils class are below:
public void sendValueToElement(String xpathSelector, String inputvalue) {
MobileElement element = (MobileElement) driver.findElementByXPath(xpathSelector);
element.setValue(inputvalue);
}
public void clickElementByXpath(String XpathSelector) {
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector)));
driver.findElement(By.xpath(XpathSelector)).click();
}
public void enterDataIntoPickerWheel(String xpathSelector, String text, int index) {
waitForElement(By.xpath(xpathSelector));
List<WebElement> we = driver.findElements(By.xpath(xpathSelector));
we.get(index).sendKeys(text);
}
Is the app working well without Appium in place. I meant install the App in Simulator and launch it and check if the app works fine.
If you see any issue then you have to fix it at that level. otherwise can you add full appium log.
To do so , you can do like below Link
To get the list of Simulators available in your system , you can type below command.Open Terminal and type below command
$ xcrun instruments -s
To launch Simulator using command line , you can type below command and provide same of simulator as you got from step 1 above
$ xcrun instruments -w "iPhone 6 (9.2)” // replace with your Simulator name
To install app on Simulator using command line once Simulator is up and running, you can type below command
$ xcrun simctl install booted <app path>
e.g.
$ xcrun simctl install booted /Users/macuser/Desktop/UIKitCatalog.app

xcodebuild failed to launch '/Applications/Xcode.app/Contents/Developer/Tools/otest' via Jenkins

error: failed to launch '/Applications/Xcode.app/Contents/Developer/Tools/otest' -- failed to get the task for process 34796
Hi,
When I run the command:
/usr/bin/xcodebuild -scheme my_scheme_name -configuration Debug build test
I get the following error:
error: failed to launch '/Applications/Xcode.app/Contents/Developer/Tools/otest' -- failed to get the task for process 34796
This only happens when the command is executed via Jenkins. Doesn't happen when I execute it from command line.
Has anyone else run into something like this?
The build itself builds an objective c library and the tests are SenTestCases. It's not an iOS app - it's an objective c library to be used in various apps
I used sudo DevToolsSecurity -enable to get past this problem.