when i run detox test,i get an error info - react-native

i'm running the demo in detox/example. but it can't run the demo normally.
i just run the following command:
1、npm install
2、npm run build:ios
3、npm run test:ios
i just got these error info in my console.
detox[30235] INFO: [DetoxServer.js] server listening on localhost:53335...
detox[30235] INFO: [AppleSimUtils.js] com.xxx.xxx.xxx.debug launched. To watch simulator logs, run:
/usr/bin/xcrun simctl spawn BE0CDB30-F235-41D2-BE85-488704F4A504 log stream --level debug --style compact --predicate 'processImagePath beginsWith "/Users/xxx/Library/Developer/CoreSimulator/Devices/BE0CDB30-F235-41D2-BE85-488704F4A504/data/Containers/Bundle/Application/460C7A3D-F8A1-4876-AFA9-3F227EEFDF64/xxx.app"'
1) "before all" hook in "{root}"
0 passing (2m)
1 failing
1) "before all" hook in "{root}":
Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
why did i get this error info? and what should i do to fix it ?

Related

Android emulator tear down during tests run

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.

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.

How to customize botium mocha timeout

I am trying to connect to directline using the following setup:
botium_directline.json:
{
"botium": {
"Capabilities": {
"PROJECTNAME": "botium-sample1",
"CONTAINERMODE": "directline3",
"DIRECTLINE3_SECRET": "<BOTIUM_SECRET>",
"DIRECTLINE3_WEBSOCKET": true
},
"Sources": {},
"Envs": {
"NODE_TLS_REJECT_UNAUTHORIZED": 0
}
}
}
Folder structure:
If I run:
botium-cli emulator browser --convos ./spec/convos --config ./botium_directline.json
I am able to "communicate with the bot" within the new conversation.
If I wanna run the tests I prepared I get the following timeouts:
botium-cli run --convos ./spec/convos/ --config ./botium_directline.json
user # /Users/username/workspace/testing/botium
~~ npm test
> botium#1.0.0 test /Users/username/workspace/testing/botium
> botium-cli run --convos ./spec/convos/ --config ./botium_directline.json
Botium Test-Suite
1) Test One
2) Test Two
0 passing (4s)
2 failing
1) Botium Test-Suite
Test One:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
2) Botium Test-Suite
Test Two:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
The error is similar to a standard mocha timeout error, but I do not know where to put a .js file to increase the timeout in a beforeEach.
I attempted to add both BOTIUM_TIMEOUT or a TIMEOUT properties into the botium_directline.json but this did not do anything.
Any ideas how to increase the timeout?
Botium automated tests have default timeout of 60000 milliseconds, but you can customize it by passing the --timeout flag at the end of your CLI command.
To do that, just add the flag --timeout followed by the time in milliseconds you'd like to set it up for. For instance, for 100000 milliseconds, your command should be like this: botium-cli emulator browser --convos ./spec/convos --config ./botium_directline.json --timeout 100000
The "BOTIUM_TIMEOUT" environment variable is the correct choice, or you can use the "--timeout" command line switch for botium-cli. This is only available since some days, there was a bug involved which has been fixed. Please get the build 0.0.34 of the botium-cli:
npm install botium-cli#0.0.34

create-react-app circle build failed

!/bin/bash -eo pipefail
yarn build
yarn run v1.6.0
$ react-scripts build
Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
events.js:183
throw er; // Unhandled 'error' event
^
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:364:12)
at PoolWorker.writeJson (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:89:22)
at PoolWorker.run (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:69:12)
at WorkerPool.distributeJob (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:326:20)
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/queue.js:10:5
at Object.process (/home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/queue.js:175:17)
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/queue.js:115:15
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/onlyOnce.js:12:16
at callback (/home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:163:21)
at /home/circleci/repo/node_modules/thread-loader/dist/WorkerPool.js:190:15
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/map.js:32:9
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/once.js:12:16
at replenish (/home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/eachOfLimit.js:61:25)
at iterateeCallback (/home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/eachOfLimit.js:50:17)
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/onlyOnce.js:12:16
at /home/circleci/repo/node_modules/thread-loader/node_modules/async/internal/map.js:29:13
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1

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