Appium/TestNG script on AWS device farm - could not find element - java

I am setting up my Appium/TestNG script in java on AWS Device Farm, using the tutorial: http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-appium-java-testng.html
After I compile and upload the 'zip-with-dependencies.zip' to AWS Device Farm and run the tests on a device, I get an error, that the first clickable element in the script could not be found.
So the Setup and Teardown suite are passing in the run, but the actual test fails every time:
Failure Description on AWS Device Farm
My question is am I missing something from the configuration or is the script in need of any extra desired capabilities in order to actually execute the test on AWS Device Farm?

I changed the version of the tested app with another one, seems like the previous one, where the element could not be found was popping out an android system message, which could not be clicked with the provided code, hence the searched element could not be found.
Another thing that device farm is not so good at - providing real time observations on the running tests, which could save a lot of time in this situations.

Answering this for people who are still facing this issue.
You have to set up the automationName desired capability to the automation mechanism that you are using to automate the tests.
For me setting it up to uiautomator2 works.
capabilities.setCapability("automationName", "uiautomator2");

Two suggestions:
1. Set element waiting time to be less than 60 seconds, because default Appium session will timeout after that.
2. Create a screenshot for the failure, check whether the element was loaded correctly.
Hope this would help:)
Thanks,
Hongda

Related

How can I send message to specific Slack channel through Selenium (Java) script if my script is running on BrowserStack through Jenkins

How can I send message to specific Slack channel through Selenium script
Working on slack notification from last few days. I'm trying to receive a message on slack which I have entered in my selenium java script.
Story:
Whenever a script runs then at particular line I have a text (Hey! Server is down.) which I want to receive it in one of the slack channel.
Please let me know how can I do it.
Thank you!
Editing and adding an update. Also here is next level question
Above problem is solved and from local its working as I installed lombok!! But will it work if my script is running on BrowserStack through Jenkins at certain interval of time?
Please let me know. Thank You!
You can send a slack notification from java program by creating a web hook. Take a look at the below link.
https://www.woolha.com/tutorials/java-sending-message-to-slack-webhook
Updating the answer with for lombok query
Lombok is only involved in the compilation phase. Refer
So if your project properly compiles without any error then it will run everywhere. You just need to have Lombok jar file on class path / maven dependency added.

failure to close UI debuggers in Chrome

We are using testng with selenium. We can use IE, Firefox or Chrome but almost always use Chrome. At the beginning of each test, a driver instance is obtained (as shown below) depending on the browser. This has been working fine but lately, and then just once, one test failed with the error message "org.openqa.selenium.SessionNotCreatedException: session not created exception
from unknown error: failed to close UI debuggers" I did some searches in Google and other people had similar problems but I did not see a lot of resolution. My guess is that it was some temporary technical glitch or network problem. But I am curious whether anyone has gotten this error, and moreover what it might mean? Not sure whether it helps, but it was developed on Eclipse, and a jar created (with a bat file to execute the tests). The tests were being run from this jar file and only one failed, and only once.
// capabilities for different browsers.
extraCapabilities.setCapability(CapabilityType.PROXY, seleniumProxyObject);
extraCapabilities.setCapability("ie.setProxyByServer", true);
extraCapabilities.setCapability("ie.usePerProcessProxy", true);
extraCapabilities.setCapability("download.default_directory", System.getProperty("java.io.tmpdir"));
// create driver with additional capabilities
webDriver = DriverFactory.getDriverInstance(driver, browser, extraCapabilities);

Selenium test in jenkins is failed (Timed out after seconds waiting for presence of element located), but locally it works fine

I have such problem. My tests successfully passed in IDEA, but Jenkins fails them and such error message appears in build log: "Timed out after 100 seconds waiting for presence of element located by: By.xpath: .//div[3]//div[4]//a" This element located in the bottom of the page, but in IDEA I have no problems with locating and interaction with it and webdriver automatically scrolls down to it. So, I've tried to replace this selector, I've tried to increase wait of this element, but I still get this error message appeared in build log. Have anybody experienced in this issue?!
I have faced similar issues many times when I run my scripts through Jenkins on remote sandbox machine. What I did was just before the script would locate for that element, I have put 5 seconds of Explicit Wait to check if the problem lies with DOM Problem(UI is loaded but background functionality still in progress of loading). Fortunately, mine worked. Hope it helps in your case. If you can provide some sample code, I may help more than this :)

Configuration of selenium webdriver with xorg-x11-server-Xvfb

We have developed selenium webdriver script with junit+java using eclipse on window 7. All the scripts are working as expected now we are using this script for load testing using Jmeter. However, while running script system open multiple browser (200) based on user thread and it create system to hang, is there any way to handle this or we can run script without opening browser. I have come across xvfb tool, but not able to get java api for this tool to plugin in eclipse.
We have also tried using HtmlUnitDriver but as it does not support javascript hence the test is getting failed, also we tried HtmlUnit and found same thing.
Note: that we have writen webdriver script to maintain display item of element (autocomplete, image) on screen.
It would be great if anyone can help or provide more inputs on this...
Firstly, do not integrate selenium scripts with JMeter for load testing! It's not a good approach to follow due to the obvious consequences that you have mentioned in your post. I followed a similar apporach in the beginning when I was new to JMeter and selenium but suffered a great deal when it came to running load tests that spawned too many browser instances which killed the OS.
You can go for HtmlUnitDriver or any headless browser testing tools out there with JMeter, but still, they will be running the browser internally in the memory. Moreover if your application is heavily using Javascript, it won't help.
So I would suggest that you record a browsing session with JMeter Proxy and modify the script (set of requests) according to your needs and play those requests alone, with number of threads.
From a higher level, you should be doing this:
Add a JMeter test plan, listeners, thread group and setup JMeter proxy and record a browsing session where you enter something into the autocomplete textbox and you get certain results.
Stop your proxy and take a look at all the requests that come under your thread group.
As far as I know, when it comes to autocomplete plugins, multiple
requests are sent everytime you enter a letter into the textbox. For
example, for the word 'stackoverflow':
Request1: q=s Request2: q=st Request3: q=sta and so on
Here you can simulate this effect by including words such that all
words have the same length which in turn will let you have same
number of requests to be sent to the server.
So in your test plan, you will pass one word per Jmeter thread. You
can pass the words to a request, from a csv file by using jmeter
parametrization.
This will be a much memory efficient way of load testing instead of using selenium with JMeter. I had asked a similar question. You can check out the responses.

Controlling The firefox launching port

I am a user of selenium webdriver and I am currently running parallel tests in my automation.I have come to understand that firefox launches from port 7054 when first launching via webdriver.I am running 10 tests at a time and I was wondering if there was some way I could control the port on which firefox browser would be launched example if I wish to launch it from port 7056 when i know another is launching from 7054. Thanks in adavnce
It seems that in theory you could do it with .setPreference(PORT_PREFERENCE, portNumber) on the FirefoxDriver, but in reality you can't change the port due to this bug that causes the default port to always override the port preference.
Unless they fixed it in the past 2 months it seems like you're out of luck; although if you are in a bind, you can grab the Selenium source and apply the fix detailed in that bug report on your own as a temporary workaround.
However, if you are running your tests from different processes, you should be able to specify -Dwebdriver.firefox.port=1234 on the command line to change the port for that particular instance of your program. I have not tried it, but the documentation shows that property.

Categories

Resources