List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java
License:Apache License
/** * the default keyboard options aren't good for automation. For instance it automatically * capitalize the first letter of sentences etc. Getting rid of all that to have the keyboard * execute requests without changing them. */// ww w.j av a 2s. c o m public void setKeyboardOptions() { File folder = new File(contentAndSettingsFolder + "/Library/Preferences/"); File preferenceFile = new File(folder, "com.apple.Preferences.plist"); try { JSONObject preferences = new JSONObject(); preferences.put("KeyboardAutocapitalization", false); preferences.put("KeyboardAutocorrection", false); preferences.put("KeyboardCapsLock", false); preferences.put("KeyboardCheckSpelling", false); writeOnDisk(preferences, preferenceFile); } catch (Exception e) { throw new WebDriverException("cannot set options in " + preferenceFile.getAbsolutePath()); } }
From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java
License:Apache License
private String getSimulateDeviceValue(Device device, DeviceVariation variation) { switch (device) { case iphone:/*from w w w . ja v a 2s . c om*/ return getIphoneString(variation); case ipad: return getIpadString(variation); default: throw new WebDriverException(device + " - " + variation + " doesn't map to a supported apple device."); } }
From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java
License:Apache License
private String getIpadString(DeviceVariation variation) { switch (variation) { case Regular: return "iPad"; case Retina:/*ww w. ja va 2s . co m*/ return "\"iPad (Retina)\""; default: throw new WebDriverException(variation + " isn't supported for ipad."); } }
From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java
License:Apache License
private String getIphoneString(DeviceVariation variation) { switch (variation) { case Regular: return "iPhone"; case Retina35: return "\"iPhone (Retina 3.5-inch)\""; case Retina4: return "\"iPhone (Retina 4-inch)\""; default:/*from www . jav a 2 s .c o m*/ throw new WebDriverException(variation + " isn't supported for ipad."); } }
From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java
License:Apache License
private void writeOnDisk(JSONObject plistJSON, File destination) throws IOException, JSONException { if (destination.exists()) { // to be on the safe side. If the emulator already runs, it won't work // anyway. throw new WebDriverException(globalPreferencePlist + "already exists.Cannot create it."); }/* ww w. java2 s .co m*/ // make sure the folder is ready for the plist file destination.getParentFile().mkdirs(); checkPlUtil(); File from = createTmpFile(plistJSON); List<String> command = new ArrayList<String>(); command.add(PLUTIL); command.add("-convert"); command.add("binary1"); command.add("-o"); command.add(destination.getAbsolutePath()); command.add(from.getAbsolutePath()); ProcessBuilder b = new ProcessBuilder(command); int i = -1; try { Process p = b.start(); i = p.waitFor(); } catch (Exception e) { throw new WebDriverException("failed to run " + command.toString(), e); } if (i != 0) { throw new WebDriverException("convertion to binary pfile failed.exitCode=" + i); } }
From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java
License:Apache License
private void checkPlUtil() { File f = new File(PLUTIL); if (!f.exists() || !f.canExecute()) { throw new WebDriverException("Cannot access " + PLUTIL); }//from ww w . j a va2s .c o m }
From source file:org.uiautomation.ios.UIAModels.predicate.AbstractCriteria.java
License:Apache License
@SuppressWarnings("unchecked") public static <T extends Criteria> T parse(JSONObject serialized, CriteriaDecorator decorator) { try {// www . j a v a 2 s.c o m int nbKeys = serialized.length(); switch (nbKeys) { case KEYS_IN_EMPTY_CRITERIA: return (T) new EmptyCriteria(); case KEYS_IN_COMPOSED_CRITERIA: String key = (String) serialized.keys().next(); CompositionType type = CompositionType.valueOf(key); return (T) buildComposedCriteria(serialized, type, decorator); case KEYS_IN_LOCATION_CRITERIA: int x = serialized.getInt("x"); int y = serialized.getInt("y"); return (T) buildLocationCriteria(serialized, x, y, decorator); case KEYS_IN_PROPERTY_CRITERIA: String method = serialized.getString("method"); String tmp = method.substring(0, 1).toUpperCase() + method.toLowerCase().substring(1) + "Criteria"; String clazz = AbstractCriteria.class.getPackage().getName() + "." + tmp; Class<? extends PropertyEqualCriteria> c = (Class<? extends PropertyEqualCriteria>) Class .forName(clazz); return (T) buildPropertyBaseCriteria(serialized, c, decorator); default: throw new InvalidSelectorException("can't find the type : " + serialized.toString()); } } catch (Exception e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.UIAModels.predicate.ComposedCriteria.java
License:Apache License
public JSONObject stringify() { JSONObject res = new JSONObject(); JSONArray or = new JSONArray(); for (Criteria c : criterias) { or.put(c.stringify());//from w w w . j a va 2 s. co m } try { res.put(type.toString(), or); } catch (JSONException e) { throw new WebDriverException(e); } return res; }
From source file:org.uiautomation.ios.UIAModels.predicate.EmptyCriteria.java
License:Apache License
@Override public void addDecorator(CriteriaDecorator decorator) { throw new WebDriverException("NI"); }
From source file:org.uiautomation.ios.UIAModels.predicate.LocationCriteria.java
License:Apache License
@Override public JSONObject stringify() { JSONObject res = new JSONObject(); try {/*ww w . j a va2s . c o m*/ res.put("x", x); res.put("y", y); } catch (JSONException e) { throw new WebDriverException(e); } return res; }