AWS appium ios test always fail - java

I am implementing aws automation testing using appium junit.
i am trying to run my testing script on aws device farm, my test script is working fine on simulator but its failing on aws devices. error does not describes the problem correctly.
Whenever i run my script on aws devices it gives me following error.
when i see the video, application was successfully launched and then nothing happens on the screen. i can see first popup that asks to allow push notifications and then after popover gets dismiss nothing happens.
failed: An error occurred while executing user supplied JavaScript.
(WARNING: The server did not provide any stacktrace information) Command
duration or timeout: 1.48 seconds Build info: version: '2.53.0', revision:
'35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'ip-172-31-13-65', ip: '172.31.13.65', os.name: 'Linux',
os.arch: 'amd64', os.version: '3.13.0-53-generic', java.version:
'1.8.0_65' Driver info: io.appium.java_client.ios.IOSDriver Capabilities
[{networkConnectionEnabled=false, desired={}, warnings={},
webStorageEnabled=false, locationContextEnabled=false, browserName=iOS,
takesScreenshot=true, javascriptEnabled=true, databaseEnabled=false,
platform=MAC}] Session ID: ca42e475-f253-40ed-a143-fef52146f655
and here is my java appium test script
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.1");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 5s");
capabilities.setCapability(CapabilityType.BROWSER_NAME, MobilePlatform.IOS);
capabilities.setCapability("autoAcceptAlerts", true);
capabilities.setCapability("showIOSLog", true);
capabilities.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, true);
String path = "/Users/home/Desktop/";
File app;
app = new File(path,"projectapp.ipa");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
URL url =new URL("http://127.0.0.1:4723/wd/hub");
driver = new IOSDriver<WebElement>(url, capabilities);
i posted a question on aws forums no one awsering.
https://forums.aws.amazon.com/thread.jspa?threadID=247887

Don't set any DesiredCapabilities except for the URL. Resources to assist further are:
The Appium Developer Guide
AWS Device Farm sample Appium tests
Step-by-step to construct Appium tests
If you need specific assistance, please open a support case with AWS or post your issue on the AWS Device Farm forum and we can assist further.

Related

Unable to maximize Safari browser on MAC with Selenium Webdriver

We are using Selenium with Java to automate our Web application. We have working code to run automated test scripts on Windows operating system for the three browsers (IE, Chrome, Firefox - Latest version).
We have got the requirement to run automated test scripts on MAC operating system - Safari browser.
Environment Details:
MAC OS version : macOS Sierra version 10.12.5
Safari browser version : 10.1.1(12603.2.4)
Selenium standalone server version : 3.4.0
Java version : 1.8.0_112
Connected MAC VM with VNC viewer (Sys admin team provided MAC VM for our testing).
While executing test scripts on MAC, below code is not maximizing Safari browser, which is working fine for other browsers(IE, Chrome and Firefox) on Windows. Due to this we are unable to locate some of the controls on application.
driver.manage().window().maximize();
We are not getting any exception, code is executing but not performing any action.
Please help to overcome Safari browser maximize issue on MAC.
Really I thought my issue got resolved with this solution, tried code to maximize Safari browser, but getting exception.
Code:
SafariOptions options = new SafariOptions();
options.setUseCleanSession(true);
driver = new SafariDriver(options);
JavascriptExecutor jse = (JavascriptExecutor)driver;
String screenWidth = jse.executeScript("return screen.availWidth").toString();
String screenHeight = jse.executeScript("return screen.availHeight").toString();
int intScreenWidth = Integer.parseInt(screenWidth);
int intScreenHeight = Integer.parseInt(screenHeight);
org.openqa.selenium.Dimension d = new org.openqa.selenium.Dimension(intScreenWidth, intScreenHeight);
driver.manage().window().setSize(d);
Exception:
Aug 07, 2017 3:11:53 PM org.openqa.selenium.remote.ProtocolHandshake
createSession INFO: Detected dialect: OSS Exception in thread "main"
org.openqa.selenium.NoSuchWindowException: A request to use a window
could not be satisfied because the window could not be found.
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 27 milliseconds Build info: version:
'3.4.0', revision: '5234b32', time: '2017-03-10 09:04:52 -0800' System
info: host: 'Mac.local', ip: 'fe80:0:0:0:4c6:11dc:3f91:11f8%en0',
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6',
java.version: '1.8.0_121' Driver info:
org.openqa.selenium.safari.SafariDriver Capabilities
[{applicationCacheEnabled=true, rotatable=false, databaseEnabled=true,
handlesAlerts=true, version=12603.3.8, cleanSession=true,
platform=MAC, nativeEvents=true, locationContextEnabled=false,
webStorageEnabled=true, browserName=safari, javascriptEnabled=true,
platformName=macOS, cssSelectorsEnabled=true}] Session ID:
BA265536-18D3-490E-B6DB-40D8BBF25937
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.setSize(RemoteWebDriver.java:860)
at Sample.Safari.main(Safari.java:20)
Safari browser maximize issue got resolved after upgrading Safari version to 11.0(12604.1.35)
And the working code is
driver.manage().window().maximize();
We have observe bug with new driver libraries. You can use slightly old jars which is able to handle new browsers versions.
You can also use other option for maximize the browser window.
Example :-
Add below option and pass it to driver :-
chromeOptions.addArguments("--start-maximized");
The full code will look like below :-
System.setProperty("webdriver.chrome.driver","D:\\Workspace\\JmeterWebdriverProject\\src\\lib\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
driver = new ChromeDriver(chromeOptions);
OR
Toolkit toolkit = Toolkit.getDefaultToolkit();
int Width = (int) toolkit.getScreenSize().getWidth();
int Height = (int)toolkit.getScreenSize().getHeight();
//For Dimension class, Import following library "org.openqa.selenium.Dimension"
driver.manage().window().setSize(new Dimension(Width,Height));
driver.get("https://google.com");
OR
((IJavaScriptExecutor)driver).ExecuteScript("window.resizeTo(1024, 768);");
Try this on safari :-
JavascriptExecutor jse = (JavascriptExecutor)driver;
String screenWidth = jse.executeScript("return screen.availWidth").toString();
String screenHeight = jse.executeScript("return screen.availHeight").toString();
int intScreenWidth = Integer.parseInt(screenWidth);
int intScreenHeight = Integer.parseInt(screenHeight);
Dimension d = new Dimension(intScreenWidth, intScreenHeight);
driver.manage.window.setSize(d);
Below article will have these example in details :-
http://www.abodeqa.com/2015/01/20/maximize-window-using-selenium-webdriver-and-by-using-abstract-window-toolkit/
Hope it will help you :)

How to run selenium tests on chrome if only binary file of chrome is placed in a server location in E drive

I have a situation in my project as below :
My code was executing as expected till the IT admin uninstalled chrome and FF from Jenkins server.
After raising a concern they placed a chrome binary in E drive .( E:\GC Local\GoogleChrome).But Chrome is not installed anywhere
I am facing issues to resolve this.
Do anyone guide here ?
Code I used :
if ("chrome".equals(browser))
{
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")
+ "\\src\\test\\resources\\drivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);
}
Will it work for you ?
ChromeOptions options = new ChromeOptions();
options.setBinary("E:\\GC Local\\GoogleChrome");
I understand that in homepath \app data chrome should be installed by default to run chrome tests. In my case , there is no chrome istalled in homepath-app but in E drive
When I used the below code :
ChromeOptions options = new ChromeOptions();
options.setBinary("E:\\GCLocal\\GoogleChrome\\GoogleChromePortable.exe");
// System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Browsers\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")
+ "\\src\\test\\resources\\drivers\\chromedriver.exe");
driver = new ChromeDriver(options);
I am getting getting the following :
T E S T S
Running TestSuite
Browser :chrome
Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 45594
Only local connections are allowed.
Error in initializing the Test .Details :-
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 62.74 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'WHIS2002', ip: '10.192.129.112', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.chrome.ChromeDriver
./TestReport.html
The above approach is correct. My issue was that portable-chrome binary refused to open due to some issues in server .code was fine.
This happened because of portable chrome binary performance issues which I solved like this :
Google Chrome Portable may run slowly from some flash drives. You can speed this up by copying GoogleChromePortable.ini from the GoogleChromePortable\Other\Source directory to the GoogleChromePortable directory and editing it to set RunLocally=true. If you do so, be sure to allow Google Chrome Portable time to copy your profile back after shutting it down. Of course, there are privacy implications to copying your personal data locally to a PC not under your control.
Thanks

Selenium firefox - WebDriverException: Reached error page: about:certerror

Meta :-
Firefox v51.0.1 (32-bit)
Windows 10
Selenium 3.0.1
Geckodriver Win32 v0.13.0
Java v1.8.0_71
Steps to reproduce :-
WebDriver driver = new FirefoxDriver();
driver.get("untrusted/self-signed URL")
Stacktrace :-
org.openqa.selenium.WebDriverException: Reached error page: about:certerror?e=nssBadCert&u=xxxxxxxx&c=UTF-8&f=regular&d=xxxxxx%20uses%20an%20invalid%20security%20certificate.%0A%0AThe%20certificate%20is%20not%20trusted%20because%20it%20is%20self-signed.%0AThe%20certificate%20is%20not%20valid%20for%20the%20name%20xxxxxx%0A%0AError%20code%3A%20%3Ca%20id%3D%22errorCode%22%20title%3D%22SEC_ERROR_UNKNOWN_ISSUER%22%3ESEC_ERROR_UNKNOWN_ISSUER%3C/a%3E%0A
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'Saurabh-PC', ip: '192.168.3.8', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_71'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Screenshot :-
I have also tried using FirefoxProfile as :-
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
dc.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(dc);
driver.get("untrusted/self-signed URL");
But issue is the same as above.
Reference Link which have tried :-
How to disable Firefox's untrusted connection warning using Selenium?
https://groups.google.com/forum/?fromgroups#!topic/webdriver/frWtNrEwNPk
Handling UntrustedSSLcertificates using WebDriver
According to this bug Support for untrusted/self-signed certificates has been added via bug 1103196 and will be available starting with Firefox 52.
But I could not find any solution for Firefox v51.0.1 (32-bit).
Is there any way to solve this issue using Firefox v51.0.1 (32-bit)?
As in this bug mentioned Support for untrusted/self-signed certificates will be available starting with Firefox 52, we need to wait until Firefox 52 is not released.
Solution :-
For now, as alternate solution we need to use existing Firefox profile where the certificate for untrusted/self-signed URL is already added into Firefox's exception list.
How to create custom Firefox profile for selenium?
Need to follow this link to create manually custom Firefox profile
Add manually certificate for untrusted/self-signed URL into Firefox's exception list
Launch Firefox using existing profile as :-
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver")
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("created Profile Name");
WebDriver driver = new FirefoxDriver(myprofile);
driver.get("untrusted/self-signed URL");

Unable to start Phantomjs driver from java .app on OSX

I have created an application on Java that starts a phantomjs driver.
My program successfully creates the phantomjs driver when launched from eclipse with the following lines:
DesiredCapabilities desireCaps = new DesiredCapabilities();
desireCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, directory + "/phantomjs");
desireCaps.setCapability("phantomjs.cli.args", Collections.singletonList("--ignore-ssl-errors=true"));
desireCaps.setCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0");
driver = new PhantomJSDriver(desireCaps);
I created an .app as such:
where "MainJar.jar" is the jar generated by eclipse,
"launcher" is the batch that basically does java -jar MainJar.app, and "phantomjs" is the selenium phantomjs official executable.
When I launch the application from the ".app", I get the following error on driver = new PhantomJSDriver(desireCaps);:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'Air-de-Me', ip: 'XXX.XXX.X.XX', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_73'
Driver info: driver.version: PhantomJSDriver
However, when I run the application by launching the "launcher" script, the application successfully creates the driver. My first though was that the "app" could not find the phantomjs driver because the path was set incorrectly, but I printed (phantomjs_file).exists(); in my log and it finds it correctly.
I have set rights on every single file inside my app and the app itself with chmod 777, just to exclude permission errors.
Is there a reason why the browser could not init?
Any help would be greatly welcome.
I have found the answer to my problem. The problem was that phantomjs could not get the permissions to write its own log file when run from the ".app".
I have found a way (the only way that worked for me), to disable phantomjs log-writting:
driver = new PhantomJSDriver(new PhantomJSDriverService.Builder()
.usingPhantomJSExecutable(new File("PATH_TO_EXECUTABLE"))
.withLogFile(null).build(),
desireCaps);

Chromedriver failing on Jenkins (Linux)

I am trying to run UI tests on Chrome on Jenkins, and from the error it appears that it is failing to start.
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 2.6.32-358.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.54 seconds (user: 'UnknownUser-0', output: '1440016601647')
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'abc.xyz.com', ip: '111.222.333.444', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.el6.x86_64', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:139)...
The code (in Java) simply tries to instantiate a default instance of Chromedriver, and fails. The following message also shows in the log, which confuses me. It appears that the driver is opening, but stopping immediately?
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 4601
Only local connections are allowed.
[0.422][WARNING]: PAC support disabled because there is no system implementation
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 9515
Only local connections are allowed.
The instantiation is done as:
WebDriver webDriver = null;
String chromeDriverLocation = MyCustomPropertyReader.getProperty("webdriver.chrome.binary.location");
System.setProperty("webdriver.chrome.driver", chromeDriverLocation);
final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
webDriver = new ChromeDriver(capabilities);
I am able to run the Chromedriver from the command prompt, and I have also checked that all the environment variables that are needed to load it up and indeed available during the instantiation.
Could someone tell me what I might be missing, or if there is a way to obtain more information about the cause of this failure?
The issue was resolved by updating the browser installation, and making sure that both Chromedriver and the Chrome browser can be run from the command prompt.

Categories

Resources