I am writing my 1st automation code for iOS device and i am seeing the following error message that I do not know how to debug..
* Error Message *
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 602.97 seconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'Husky-MacBook-Air.local', ip: '10.131.32.153', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.4', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
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: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:153)
at com.husky.test1.Appium_take1.main(Appium_take1.java:43)
***** End of Error Message ******
I am using Appium 1.2 and here is my code:
* Code *
package com.husky.test1;
import java.io.File;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
public class Appium_test1 {
public static void main(String... args){
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("device", "iPhone");
desiredCapabilities.setCapability("version", "7.1");
desiredCapabilities.setCapability("app", "/Users/cutehusky/Downloads/Payload2/test.app");
desiredCapabilities.setCapability("platformName", "iOS");
desiredCapabilities.setCapability("deviceName", "iPhone");
URL url = null;
WebDriver remoteWebDriver = new RemoteWebDriver(url,desiredCapabilities);
By b = By.xpath("UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[5]/UIAStaticText[1]");
WebElement we = remoteWebDriver.findElement(b);
we.click();
}
}
** End of Automation Code **
Explain:
I am trying to launch my test app under "/Users/cutehusky/Downloads/Payload2/test.app", find a button base on its xpath (UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[5]/UIAStaticText[1]) and click on it.
Thats all I am looking to accomplish at the moment, please help me :)
Thanks
So the following tells you everything you need to know:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
When you begin your test, you need to make sure the following things aren't running:
Appium sometimes gets into a state where it thinks the Simulator is running, but it's not. This is solved by restarting the server.
Instead of remote webdriver use below code
protected static AppiumDriver<MobileElement> driver;
driver = new IOSDriver<MobileElement>(url, dCapabilities);
and try to run if it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.