I am trying to test Android device on MAC OS X, using Appium (in Java).
The build path includes these:
java-client-<version>.jar
java-client-<verson>-sources.jar
selenium-java-<version>.jar
selenium-server-standalone-<version>.jar
(the version of the last 2 is the same), and TestNG.
Starting the Appium server (i am using the GUI) works fine and the application (which is already installed on the device) launches. Starting to debug my eclipse project which contains the following lines, i am getting the error for the 3rd line.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Plus");
AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
The full error i am getting is:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. Details: Problem getting session data for driver type AndroidDriver; does it implement 'get driverData'?
You're saying that using the GUI launches the application? If that's the case, and what you're showing in code is your full DesiredCapabilities, then your capabilities would be the problem.
You can see what the capabilities the Appium GUI is using at the top with the text "Launching Appium with command".
If you set those flags in your capabilities, then the driver should connect properly.
You forgot to close the appium session by use driver.close()?
Try to restart your appium server.
P/s: When you don't want to close driver, you need enable Session override in appium GUI settings or add --session-override in appium command line. Then you don't need to restart appium server
Related
I am getting connection refused error while creating a firefox driver.
System.setProperty("webdriver.gecko.driver", "path to gecko driver");
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
options.setAcceptInsecureCerts(true);
options.addArguments("-profile", "./firefoxprofile");
options.setHeadless(true);
LOGGER.info("Completed setting firefox optons");
WebDriver driver = new FirefoxDriver(options);
Log:
1550014357421 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "./firefoxprofile" "-foreground" "-no-remote"
1550014357464 geckodriver::marionette DEBUG Waiting 60s to connect to browser on 127.0.0.1:61008
[GFX1-]: [OPENGL] Failed to init compositor with reason: FEATURE_FAILURE_OPENGL_CREATE_CONTEXT
Can't find symbol 'GetGraphicsResetStatus'.
1550014417545 mozrunner::runner DEBUG Killing process 38393
Exiting due to channel error.
1550014417592 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"unknown error","message":"connection refused","stacktrace":""}}
Web server is running and I could able to test it with curl command and I tried with 777 permissions on gecko driver bin file.
Also updated Gecko driver to latest version (0.24.0)
Your configurations looks good.
I had a similar problems in Linux.
In my case the solution was test with all versions of gecko driver and with one of them, it worked.
Also you can check if the o.s user of your IDE (eclipse, intellij) is the same user of the firefox. In my case, eclipse was starting with root but firefox could not start with root user.
I hope this help you.
While working with Selenium v3.x, GeckoDriver v0.24.0 and Firefox Quantum v65.0 to use a new Firefox Profile on every run of your Test Execution you can use the following code block :
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setProfile(new FirefoxProfile());
options.setLogLevel(FirefoxDriverLogLevel.FATAL);
options.setAcceptInsecureCerts(true);
options.setHeadless(true);
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.google.com");
You can find a detailed discussion in Cannot resolve constructor FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)
I was facing the same problem in Windows using python. Make sure that your Firefox browser version is also the latest one.
After searching a lot, I finally found it was because a previous instance of the browser was running. Keep in mind, not another instance like one opened by me but an instance which was previously opened by selenium. If you can, close all the background browser processes. I restarted my system and it works perfectly fine as long as I remember to do browser.quit().
If you stop the program before closing the object properly, there is a chance the background instance will keep running unless eclipse or whichever IDE you are using closes it.
I am running the tests on a hybrid app. My configuration is: Xcode version set to '9.2' (tools v9.3.0.0.1.1521514116), Appium 1.7.2, and the capabilities are:
capabilities.setCapability("xcodeConfigFile", "/path/to/xcodeConfigFile.xcconfig");
capabilities.setCapability("newCommandTimeout", 600);
capabilities.setCapability("nativeWebTap", "true");
capabilities.setCapability("noReset", "true");
capabilities.setCapability("fullReset", "false");
capabilities.setCapability("chromedriverExecutable", chromeDriver);
capabilities.setCapability("bootstrapPath", "/Upath/to/appium-xcuitest-driver/WebDriverAgent");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
capabilities.setCapability("udid", UDID);
capabilities.setCapability("platformVersion", "11.2.6");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, platform);
capabilities.setCapability("app", iOSAppPath);
capabilities.setCapability("automationName" , "XCUITest");
If I use capabilities.setCapability("autoWebview", "true") the tests is stuck at driver initialization, as it does not find any webview.
webDriver.getContextHandles() returns only NATIVE_APP on a real device, but also returns WEBVIEW_2908.1 on the simulator.
The external libraries used are:
SaxonLiaison.jar
commons-lang3-3.1.jar
commons-validator-1.4.0.jar
guice-3.0.jar
java-client-4.1.2.jar
jcommander.jar
jxl-2.6.10.jar
log4j-1.2.16.jar
poi-3.10.1-20140818.jar
reportng-1.1.4.jar
saxon-8.7.jar
selenium-server-standalone-2.53.0.jar
smslib-3.5.4.jar
testng-6.8.21.jar
velocity-dep-1.4.jar
xslt.jar
I am unable to update to newer version because I get errors for some functionalities implemented in java-client-4.1.2.jar (for example webDriver.tap() )
As found on appium.io and other questions, I installed everything I could, like: ios-webkit-debug-proxy, libimobiledevice and ios-deploy
Edit: before I did not know that I had to manually run ios_webkit_debug_proxy, so I ran it three times with three different ports: 9221, 9222 and 9223, I received the same result and this is the only thing that was logged in the terminal:
ios_webkit_debug_proxy -c <udid>:9222
Connected :9222 to iPhone X (<udid>)
I found the solution to my issue here: https://github.com/appium/appium/issues/7676
I just had to start ios_webkit_debug_proxy and start appium server with a parameter that points to the ios_webkit_debug_proxy port
ios_webkit_debug_proxy -c UDID:27753 -d
appium --no-reset --webkit-debug-proxy-port 27753
My environment:
linux ubuntu
selenium-html-runner-3.4.0.jar
selenium-java-3.4.0
selenium-server-standalone-3.4.0.jar
to build I do:
javac -cp "/usr/share/java/junit.jar:/home/me/ushare/hobo/selenium/selenium-html-runner-3.4.0.jar:." TestHobo2.java
to run selenium-server:
java -jar selenium-server-standalone-3.4.0.jar
to run the test I do:
java junit.textui.TestRunner TestHobo2
and I get:
java.lang.RuntimeException: Could not start Selenium session:
at
com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:114)
at
com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:139)
at
com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:108)
at
com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:113)
at TestHobo2.setUp(TestHobo2.java:10) at
com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:289)
Caused by: com.thoughtworks.selenium.SeleniumException:
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:111)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:105)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:277)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:239)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:105)
... 15 more
Here is my test case:
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class TestHobo2 extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.example.com/", "*chrome");
}
public void testGetLink() throws Exception {
selenium.type("name=p_loc", "groove");
selenium.click("css=input[type=\"Submit\"]");
selenium.waitForPageToLoad("30000");
}
}
Edit 2017/07/20 More info:
I am using Firefox version 52.0.2 (64-bit).
Should I be getting the following after the build?
Note: TestHobod2.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
geckodriver -v
1500554646753 geckodriver INFO geckodriver 0.18.0
1500554646753 webdriver::httpapi DEBUG Creating routes
1500554646764 geckodriver ERROR Address in use (os error 98)
Are you sure that you have properly defined on which ip address and port is selenium running? Run your selenium server and put http://127.0.0.1:4444/wd/hub/ link into your browser. Try to create new session manually (click on create session and select browser, see image below), new browser blank window should appear. If this is working correctly than selenium server is ok. Then there can be problem with connection between server and your runner.
screen of selenium hub with create session option
Do you have correctly setup selenium driver? For example I'm using
new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub/"),DesiredCapabilities.firefox())
EDIT1: Show example of setUp method which create instance of RemoteDriver, create new browser session and fill url.
WebDriver driver = new RemoteWebDriver(new URL("http://192.168.4.52:4444/wd/hub"), DesiredCapabilities.firefox());
driver.manage().window().maximize()//maximaze window as possible
driver.get("www.google.com"); //navigate to google, i.e. fill url into opened session
Looking at the codebase, and trying to map your shared test code, seems to suggest that you will end up invoking a Firefox browser. The underlying implementation in Selenium has ensured that this will cause your test code to resort to perhaps using firefox.
Can you please ensure that you have made geckodriver downloaded and made available in your PATH variable ?
If that doesn't fix the problem (which could mostly be due to mismatch between the firefox version that you have in your desktop and the geckodriver version ), you can try switching to using Google Chrome.
You can switch to google chrome by
Changing : setUp("http://www.example.com/", "*chrome");
To : setUp("http://www.example.com/", "*googlechrome");
And see if that spins off the browser (For google chrome you would need to ensure you have chromedriver downloaded and made available in your local machine)
I tried to navigate URL with MS Edge Browser but it giving me error.
My Environment is as follows:
Windows: 10 64x pro.
Browser: MS Edge 25.10586.0.0
Selenium WebDriver: 2.48.2
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class edgeBrowser {
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver",
"C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
driver.get("http://www.google.com");
}
}
MS edge browser opens but it does not navigate to google.com and I received following error
Received a request for http://localhost:17347/session
Existing Microsoft Edge process (pid: 64400) terminated forcibly.
Waiting for new request...
Received a request for http://localhost:17347/shutdown
Stopping server.
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 6.79 seconds
I had the same issue (if I recall) and the solution for me was to install the driver presented as:
For the latest preview build from the Windows Insider Program, install
this version of Microsoft WebDriver
Listed here:
WebDriver for Microsoft Edge (Windows)
We had the same issue and after so much of struggle we found the solution which works fine for us.
Microsoft has made Microsoft WebDriver a Feature on Demand (FoD) to make it easier to get the right version for your device.
The simplest way to get started is to enable Developer Mode. Open the Settings app and go to “Update & Security,” “For developers,” and select “Developer Mode.” The appropriate version of WebDriver will be automatically installed.
You can also install a standalone version of WebDriver in one of two ways:
Search “Manage optional features” from Start, then select “Add a Feature,” “WebDriver.”
Install via DISM by running the following command in an elevated command prompt:DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
You can checkout the complete steps in this blog : https://techminionsite.com/fix-for-microsoft-webdriver-windows-10-issue/
Is there any way how to run Selenium automation test in Internet Explorer 9 in InPrivate mode with IEDriverServer?
I need to test 2 (two) testcases:
1. browser is closed. Open one window of IE InPrivate mode. Run test.
2. browser is opened in normal mode. Open new window of IE InPrivate mode. Run test.
How should JAVA code look for this tests?
Thank you
public void openBrowserInPrivacyMode(boolean isBrowserActive) {
System.setProperty("webdriver.ie.driver", "path/to/IEDriverServer_x32.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
сapabilities.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
InternetExplorerDriver driver = new InternetExplorerDriver(capabilities);
#Roman's solution is now deprecated.
The new way to do this is as follows:
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
ieOptions.addCommandSwitches("-private");
InternetExplorerDriver driver = InternetExplorerDriver(ieOptions));
Also, I had problems doing this, until I set a TabProcGrowth registry value. Before doing this I got the following exception:
org.openqa.selenium.SessionNotCreatedException: Unexpected error launching Internet Explorer.
Unable to use CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher,
the value of registry setting in
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'.
I had this with happening with Windows 10 and Selenium 3.14. Curiously enough, setting the TabProcGrowth value also fixed this for me.