List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.UIAModels.predicate.PropertyEqualCriteria.java
License:Apache License
public JSONObject stringify() { JSONObject res = new JSONObject(); try {//from www . j ava2 s.c om res.put("method", propertyName); res.put("expected", value); res.put("l10n", l10nstrategy); res.put("matching", matchingStrategy); } catch (JSONException e) { throw new WebDriverException(e); } return res; }
From source file:org.uiautomation.ios.utils.Command.java
License:Apache License
/** * execute the command, and wait for it to finish. Also wait for stdout and std err listener to * finish processing their streams.//from w w w . ja v a 2s .c o m */ public void executeAndWait() { start(); int exitCode = waitFor(-1); if (exitCode != 0) { throw new WebDriverException("execution failed. Exit code =" + exitCode + " , command was : " + args); } for (Thread t : threads) { try { t.join(); } catch (InterruptedException e) { throw new WebDriverException(e); } } }
From source file:org.uiautomation.ios.utils.ScriptHelper.java
License:Apache License
public File createTmpScript(String content) { try {// w ww . j a va2s .c om File res = File.createTempFile(FILE_NAME, ".js"); res.deleteOnExit(); Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(res), "UTF-8")); writer.write(content); writer.close(); return res; } catch (Exception e) { throw new WebDriverException("Cannot generate script."); } }
From source file:org.uiautomation.ios.utils.SimulatorSettings.java
License:Apache License
public void setMobileSafariOptions() { File folder = new File(contentAndSettingsFolder + "/Library/Preferences/"); File preferenceFile = new File(folder, "com.apple.mobilesafari.plist"); try {/*from w ww. jav a2 s.co m*/ JSONObject preferences = new JSONObject(); preferences.put("WarnAboutFraudulentWebsites", false); writeOnDisk(preferences, preferenceFile); } catch (Exception e) { throw new WebDriverException("cannot set options in " + preferenceFile.getAbsolutePath()); } }
From source file:org.uiautomation.ios.utils.SimulatorSettings.java
License:Apache License
private String getSimulateDeviceValue(DeviceType device, DeviceVariation variation) { switch (device) { case iphone:// w ww . j a va 2s .c o m 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.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."); }/*from w ww . j av a2 s.c o 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.webInspector.DOM.DOM.java
License:Apache License
public static JSONObject resolveNode(NodeId id) { JSONObject cmd = new JSONObject(); try {//from w w w.j a v a2 s . c o m cmd.put("method", "DOM.resolveNode"); cmd.put("params", new JSONObject().put("nodeId", id.getId())); return cmd; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.webInspector.DOM.DOM.java
License:Apache License
public static JSONObject querySelector(NodeId id, String selector) { try {//from w w w . j av a 2 s . c o m JSONObject cmd = new JSONObject(); cmd.put("method", "DOM.querySelector"); cmd.put("params", new JSONObject().put("nodeId", id.getId()).put("selector", selector)); return cmd; } catch (Exception e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.webInspector.DOM.DOM.java
License:Apache License
public static JSONObject querySelectorAll(NodeId id, String selector) { try {//from w w w. j a v a2s . c om JSONObject cmd = new JSONObject(); cmd.put("method", "DOM.querySelectorAll"); cmd.put("params", new JSONObject().put("nodeId", id.getId()).put("selector", selector)); return cmd; } catch (Exception e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.webInspector.DOM.DOM.java
License:Apache License
public static JSONObject highlightNode(NodeId id) { try {/*from w w w . j av a2s. co m*/ JSONObject color = new JSONObject().put("a", 0.5).put("r", 50).put("g", 100).put("b", 255); JSONObject cmd = new JSONObject(); cmd.put("method", "DOM.highlightNode"); cmd.put("params", new JSONObject().put("nodeId", id.getId()).put("highlightConfig", new JSONObject().put("showInfo", true).put("contentColor", color))); return cmd; } catch (JSONException e) { throw new WebDriverException(e); } }