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

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

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.

Selenium with Firefox-ESR in Alpine Docker image

I'm using Selenium for testing from Java code, it's started automatically with maven, when I run mvn verify it uses gecko-driver to start new firefox instance for selenium:
final FirefoxOptions opts = new FirefoxOptions();
if (HEADLESS_MODE) {
opts.addArguments(ARG_HEADLESS);
}
return new FirefoxDriver(opts);
It's working fine on my machine (and on machines of other developers) in both modes "headless" and normal. Now I'm trying to run Selenium tests with CI builds in Alpine Linux Docker container. When I tried to run it as-is, I've got an error:
mozrunner::runner INFO Running command: "/usr/bin/firefox"
"-marionette" "--headless" "-foreground" "-no-remote"
"-profile" "/tmp/rust_mozprofile.pW1sbkcv98QN"
Error: GDK_BACKEND does not match available displays.
Then I installed all suggested tools (dbus and xvfb) from this post and started it before running tests:
apk add xvfb dbus
dbus-uuidgen > /etc/machine-id
export DISPLAY=:99
Xvfb $DISPLAY -ac &
mvn verify
but now Selenium tests are hadning for about 10 seconds and failing with error
1565433736375 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "--headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.1ZMsJ0Hy95V0"
1565433738424 Marionette INFO Listening on port 2828
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
It seems I'm doing something wrong here, what is the correct way to run headless Selenium tests in Alpine Linux Docker container? I'd prefer to configure existing Docker image instead of using Selenium images, because the migration will be expensive.
Update:
Selenium version is 3.141.59
Gecko-driver version is v0.24.0-linux64
Firefox-ESR version is: 52.8.1-r0
Update2:
xvfb, dbus and exported DISPLAY are not actually needed to run Firefox in headless mode - just run firefox --headless and it's all.
As per Mozilla --headless flag is not supported in Firefox 52-esr.Headless flag was introduced in version 55 (for Linux) and 56 (Mac/Windows) . Please try on latest Firefox ESR release.

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 to I pass GIT's username and password to gradle plugin?

I'm trying to release using the gradle release plugin but whenever the plugin is using GIT, it's not passing my username and password:
I 'm invoking it as:
I'm using:
C:\GradleReleaseTest>gradle --version
------------------------------------------------------------
Gradle 2.11
------------------------------------------------------------
Build time: 2016-02-08 07:59:16 UTC
Build number: none
Revision: 584db1c7c90bdd1de1d1c4c51271c665bfcba978
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_66 (Oracle Corporation 25.66-b18)
OS: Windows 7 6.1 amd64
My gradle release configuration looks as:
release {
failOnCommitNeeded = true
failOnPublishNeeded = true
failOnSnapshotDependencies = true
failOnUnversionedFiles = true
failOnUpdateNeeded = true
revertOnFail = true
preCommitText = ''
preTagCommitMessage = '[Gradle Release Plugin] ${release.releaseVersion} - pre tag commit: '
tagCommitMessage = '[Gradle Release Plugin] ${release.releaseVersion} - creating tag : '
newVersionCommitMessage = '[Gradle Release Plugin] ${release.releaseVersion} - new version commit: '
tagTemplate = '${version}'
// May decide to add additional custom tasks here
buildTasks = ['build']
scmAdapters = [
net.researchgate.release.GitAdapter
]
}
The error I'm getting looks like:
C:\GradleReleaseTest>gradle release -Prelease.releaseVersion=1
.0.0 -Prelease.newVersion=1.0.1-SNAPSHOT -Prelease.username=jvergara -Prelease.p
assword=thePassword
:release
:com.mycompany.gradletest:createScmAdapter
:com.mycompany.gradletest:initScmAdapter
:com.mycompany.gradletest:checkCommitNeeded
:com.mycompany.gradletest:checkUpdateNeeded
Running [git, remote, update] produced an error: [bash: /dev/tty: No such device
or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.mycompany.com': Invalid ar
gument
error: Could not fetch origin]
:com.mycompany.gradletest:checkUpdateNeeded FAILED
:release FAILED
Release process failed, reverting back any changes made by Release Plugin.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkUpdateNeeded'.
> Failed to run [git remote update] - [Fetching origin
][bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://git.mycompany.com': Invalid ar
gument
error: Could not fetch origin
]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 5.912 secs
I managed to resolve this. The problem has nothing to do with the plugin at all, but rather how git itself work.
You either have to use a global config for the credentials or you have to use local config
See, https://git-scm.com/docs/gitcredentials. I used the local version and it works just fine.

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.