Java Code Examples for com.gargoylesoftware.htmlunit.BrowserVersion#FIREFOX_60
The following examples show how to use
com.gargoylesoftware.htmlunit.BrowserVersion#FIREFOX_60 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HtmlUnitRegExpProxy3Test.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Compute replacement value. Following cases occur: * - Invalid back references are treated as it in JS but not in Java. * - $$: should be replaced by $ */ @Test public void computeReplacementValue() { final String theString = "hello"; final Matcher matcher0group = Pattern.compile("h").matcher("hello"); final Matcher matcher1group = Pattern.compile("(h)").matcher("hello"); matcher1group.find(); final HtmlUnitRegExpProxy proxy = new HtmlUnitRegExpProxy(null, BrowserVersion.FIREFOX_60); assertEquals("$", proxy.computeReplacementValue("$$", theString, matcher0group, false)); assertEquals("$$x$", proxy.computeReplacementValue("$$$$x$$", theString, matcher0group, false)); assertEquals("$1", proxy.computeReplacementValue("$1", theString, matcher0group, false)); assertEquals("$2", proxy.computeReplacementValue("$2", theString, matcher0group, false)); assertEquals("h", proxy.computeReplacementValue("$1", theString, matcher1group, false)); assertEquals("$2", proxy.computeReplacementValue("$2", theString, matcher1group, false)); assertEquals("$", proxy.computeReplacementValue("$", theString, matcher0group, false)); assertEquals("$", proxy.computeReplacementValue("$", theString, matcher1group, false)); assertEquals("\\\\$", proxy.computeReplacementValue("\\\\$", theString, matcher1group, false)); assertEquals("$", proxy.computeReplacementValue("$", theString, matcher1group, false)); }
Example 2
Source File: DebugFrameImplTest.java From htmlunit with Apache License 2.0 | 5 votes |
/** * Constructor. * @throws Exception if an exception occurs */ public DebugFrameImplTest() throws Exception { client_ = new WebClient(BrowserVersion.FIREFOX_60); ((JavaScriptEngine) client_.getJavaScriptEngine()).getContextFactory().setDebugger(new DebuggerImpl()); originalLogLevel_ = loggerDebugFrameImpl_.getLevel(); loggerDebugFrameImpl_.setLevel(Level.TRACE); }
Example 3
Source File: BrowserVersionClassRunner.java From htmlunit with Apache License 2.0 | 5 votes |
private void setAlertsStandards(final WebTestCase testCase, final Method method) { final AlertsStandards alerts = method.getAnnotation(AlertsStandards.class); if (alerts != null) { String[] expectedAlerts = NO_ALERTS_DEFINED; if (isDefined(alerts.value())) { expectedAlerts = alerts.value(); } else { if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) { expectedAlerts = firstDefined(alerts.IE(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_60) { expectedAlerts = firstDefined(alerts.FF60(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_68) { expectedAlerts = firstDefined(alerts.FF68(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX) { expectedAlerts = firstDefined(alerts.FF(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.CHROME) { expectedAlerts = firstDefined(alerts.CHROME(), alerts.DEFAULT()); } } testCase.setExpectedAlerts(expectedAlerts); } else { setAlerts(testCase, method); } }
Example 4
Source File: BrowserVersionClassRunner.java From htmlunit with Apache License 2.0 | 5 votes |
/** * Returns true if current {@link #browserVersion_} is contained in the specific <tt>browsers</tt>. */ private boolean isDefinedIn(final TestedBrowser[] browsers) { for (final TestedBrowser browser : browsers) { switch (browser) { case IE: if (browserVersion_.isIE()) { return true; } break; case FF60: if (browserVersion_ == BrowserVersion.FIREFOX_60) { return true; } break; case FF68: if (browserVersion_ == BrowserVersion.FIREFOX_68) { return true; } break; case FF: if (browserVersion_ == BrowserVersion.FIREFOX) { return true; } break; case CHROME: if (browserVersion_.isChrome()) { return true; } break; default: } } return false; }
Example 5
Source File: Geolocation.java From htmlunit with Apache License 2.0 | 4 votes |
private void doGetPosition() { final String os = System.getProperty("os.name").toLowerCase(Locale.ROOT); String wifiStringString = null; if (os.contains("win")) { wifiStringString = getWifiStringWindows(); } if (wifiStringString != null) { String url = PROVIDER_URL_; if (url.contains("?")) { url += '&'; } else { url += '?'; } url += "browser=firefox&sensor=true"; url += wifiStringString; while (url.length() >= 1900) { url = url.substring(0, url.lastIndexOf("&wifi=")); } if (LOG.isInfoEnabled()) { LOG.info("Invoking URL: " + url); } try (WebClient webClient = new WebClient(BrowserVersion.FIREFOX_60)) { final Page page = webClient.getPage(url); final String content = page.getWebResponse().getContentAsString(); if (LOG.isDebugEnabled()) { LOG.debug("Receieved Content: " + content); } final double latitude = Double.parseDouble(getJSONValue(content, "lat")); final double longitude = Double.parseDouble(getJSONValue(content, "lng")); final double accuracy = Double.parseDouble(getJSONValue(content, "accuracy")); final Coordinates coordinates = new Coordinates(latitude, longitude, accuracy); coordinates.setPrototype(getPrototype(coordinates.getClass())); final Position position = new Position(coordinates); position.setPrototype(getPrototype(position.getClass())); final WebWindow ww = getWindow().getWebWindow(); final JavaScriptEngine jsEngine = (JavaScriptEngine) ww.getWebClient().getJavaScriptEngine(); jsEngine.callFunction((HtmlPage) ww.getEnclosedPage(), successHandler_, this, getParentScope(), new Object[] {position}); } catch (final Exception e) { LOG.error("", e); } } else { if (LOG.isErrorEnabled()) { LOG.error("Operating System not supported: " + os); } } }
Example 6
Source File: WindowConcurrencyTest.java From htmlunit with Apache License 2.0 | 4 votes |
/** * Regression test for * <a href="http://sourceforge.net/support/tracker.php?aid=2820051">bug 2820051</a>. * @throws Exception if the test fails */ @Test public void concurrentModificationException_computedStyles() throws Exception { final String html = "<html><head><script>\n" + "function test() {\n" + " getComputedStyle(document.body, null);\n" + "}\n" + "</script></head><body onload='test()'>\n" + "<iframe src='foo.html' name='myFrame' id='myFrame'></iframe>\n" + "</body></html>"; final String html2 = "<html><head><script>\n" + "function forceStyleComputationInParent() {\n" + " var newNode = parent.document.createElement('span');\n" + " parent.document.body.appendChild(newNode);\n" + " parent.getComputedStyle(newNode, null);\n" + "}\n" + "setInterval(forceStyleComputationInParent, 10);\n" + "</script></head></body></html>"; try (WebClient client = new WebClient(BrowserVersion.FIREFOX_60)) { final MockWebConnection webConnection = new MockWebConnection(); webConnection.setResponse(URL_FIRST, html); webConnection.setDefaultResponse(html2); client.setWebConnection(webConnection); final HtmlPage page1 = client.getPage(URL_FIRST); // Recreating what can occur with two threads requires // to know a bit about the style invalidation used in Window.DomHtmlAttributeChangeListenerImpl final HtmlElement elt = new HtmlDivision("div", page1, new HashMap<String, DomAttr>()) { @Override public DomNode getParentNode() { // this gets called by CSS invalidation logic try { Thread.sleep(1000); // enough to let setInterval run } catch (final InterruptedException e) { throw new RuntimeException(e); } return super.getParentNode(); } }; page1.getBody().appendChild(elt); } }
Example 7
Source File: BrowserVersionClassRunner.java From htmlunit with Apache License 2.0 | 4 votes |
private void setAlerts(final WebTestCase testCase, final Method method) { final Alerts alerts = method.getAnnotation(Alerts.class); String[] expectedAlerts = {}; if (alerts != null) { expectedAlerts = NO_ALERTS_DEFINED; if (isDefined(alerts.value())) { expectedAlerts = alerts.value(); } else { if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) { expectedAlerts = firstDefined(alerts.IE(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_60) { expectedAlerts = firstDefined(alerts.FF60(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_68) { expectedAlerts = firstDefined(alerts.FF68(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX) { expectedAlerts = firstDefined(alerts.FF(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.CHROME) { expectedAlerts = firstDefined(alerts.CHROME(), alerts.DEFAULT()); } } } if (isRealBrowser()) { final BuggyWebDriver buggyWebDriver = method.getAnnotation(BuggyWebDriver.class); if (buggyWebDriver != null) { if (isDefined(buggyWebDriver.value())) { expectedAlerts = buggyWebDriver.value(); } else { if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.IE(), buggyWebDriver.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_60) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.FF60(), buggyWebDriver.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_68) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.FF68(), buggyWebDriver.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.FF(), buggyWebDriver.DEFAULT()); } else if (browserVersion_ == BrowserVersion.CHROME) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, buggyWebDriver.CHROME(), buggyWebDriver.DEFAULT()); } } } } else { final HtmlUnitNYI htmlUnitNYI = method.getAnnotation(HtmlUnitNYI.class); if (htmlUnitNYI != null) { if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.IE()); } else if (browserVersion_ == BrowserVersion.FIREFOX_60) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF60()); } else if (browserVersion_ == BrowserVersion.FIREFOX_68) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF68()); } else if (browserVersion_ == BrowserVersion.FIREFOX) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF()); } else if (browserVersion_ == BrowserVersion.CHROME) { expectedAlerts = firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.CHROME()); } } } testCase.setExpectedAlerts(expectedAlerts); }
Example 8
Source File: HiddenBrowserDriver.java From ats-framework with Apache License 2.0 | 4 votes |
/** * To get HiddenBrowserDriver instance use UiDriver.getHiddenBrowserDriver() * @param url application url */ protected HiddenBrowserDriver( String url ) { this.url = url; this.browserVersion = BrowserVersion.FIREFOX_60; }