List<HtmlAnchor> contactTabs = (List<HtmlAnchor>) gameLoggedInPage.getByXPath("//a[@class='nav-lnk'])"); HtmlAnchor contacts = contactTabs.get(1); HtmlPage page = contacts.click();
/** * <p>Click the specified hyperlink, and retrieve the subsequent page, * saving a reference so that other utility methods may be used to * retrieve information from it.</p> * * @param anchor Anchor component to click * * @exception IOException if an input/output error occurs */ protected HtmlPage link(HtmlAnchor anchor) throws IOException { HtmlPage page = (HtmlPage) anchor.click(); this.page = page; return page; }
/** * <p>Click the specified hyperlink, and retrieve the subsequent page, * saving a reference so that other utility methods may be used to * retrieve information from it.</p> * * @param anchor Anchor component to click * * @exception IOException if an input/output error occurs */ protected HtmlPage link(HtmlAnchor anchor) throws IOException { HtmlPage page = (HtmlPage) anchor.click(); this.page = page; return page; }
HtmlAnchor anchor = (HtmlAnchor)page.getHtmlElementById("second_page_link"); page = (HtmlPage) anchor.click();
/** * <p>Click the specified hyperlink, and retrieve the subsequent page, * saving a reference so that other utility methods may be used to * retrieve information from it.</p> * * @param anchor Anchor component to click * * @exception IOException if an input/output error occurs */ protected HtmlPage link(HtmlAnchor anchor) throws IOException { HtmlPage page = (HtmlPage) anchor.click(); this.page = page; return page; }
/** * <p>Click the specified hyperlink, and retrieve the subsequent page, * saving a reference so that other utility methods may be used to * retrieve information from it.</p> * * @param anchor Anchor component to click * * @exception IOException if an input/output error occurs */ protected HtmlPage link(HtmlAnchor anchor) throws IOException { HtmlPage page = (HtmlPage) anchor.click(); this.page = page; return page; }
/** * <p>Click the specified hyperlink, and retrieve the subsequent page, * saving a reference so that other utility methods may be used to * retrieve information from it.</p> * * @param anchor Anchor component to click * * @exception IOException if an input/output error occurs */ protected HtmlPage link(HtmlAnchor anchor) throws IOException { HtmlPage page = (HtmlPage) anchor.click(); this.page = page; return page; }
HtmlAnchor link = page.getFirstByXPath("//a[@href='javascript:loadRankingTable(3);']"); link.click();
@Override public void clickLinkWithExactText(String linkText, int index) { HtmlAnchor link = getLinkWithExactText(linkText, index); if (link == null) { throw new RuntimeException("No Link found for \"" + linkText + "\" with index " + index); } try { link.click(); } catch (IOException e) { throw new RuntimeException("Click failed", e); } }
@Override public void clickLinkWithText(String linkText, int index) { HtmlAnchor link = getLinkWithText(linkText, index); if (link == null) { throw new RuntimeException("No Link found for \"" + linkText + "\" with index " + index); } try { link.click(); } catch (IOException e) { throw new RuntimeException("Click failed", e); } }
public void testHomePage() throws Exception { final WebClient webClient = new WebClient(); final URL url = new URL("http://htmlunit.sourceforge.net"); final HtmlPage page = (HtmlPage)webClient.getPage(url); HtmlAnchor anchor = page.getAnchorByName("Home"); anchor.click(); }
HtmlAnchor link = null; for (HtmlAnchor anchor : anchors) { String str = anchor.asText(); if (anchor.asText().equals("Start")) link = anchor; } HtmlPage page2 = link.click();
HtmlPage page = webClient.getPage("https://www.yourwebsite.com/#"); HtmlAnchor link=page.getElementByName("link"); link.click(); page.refresh();
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF); WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); HtmlPage currentPage = webClient.getPage("http://www.google.com/"); HtmlAnchor advancedSearchAn = currentPage.getAnchorByText("About"); currentPage = advancedSearchAn.click();
WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage("http://yourpage.com"); HtmlAnchor anchor = page.getAnchorByText("Enter a"); page = anchor.click();
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { HtmlPage page = webClient.getPage("http://www.google.com"); HtmlAnchor a = page.getHtmlElementById("gb_70"); page = a.click(); HtmlForm form = (HtmlForm) page.getElementById("gaia_loginform"); HtmlTextInput email = (HtmlTextInput) page.getElementById("Email"); email.setValueAttribute(myEmailAddress); HtmlSubmitInput nextButton = page.getHtmlElementById("next"); System.out.println(nextButton.asXml()); HtmlPage newWebpage = nextButton.click(); String status = newWebpage.getWebResponse().getStatusMessage(); System.out.println(status); }
@Issue("JENKINS-52164") @Test public void renameLinksShouldBeValid() throws Exception { FreeStyleProject project1 = r.createFreeStyleProject(); Folder folder1 = createFolder(); FreeStyleProject project2 = folder1.createProject(FreeStyleProject.class, "project2"); HtmlAnchor anchor = findRenameAnchor(project1); anchor.click(); anchor = findRenameAnchor(project2); anchor.click(); anchor = findRenameAnchor(folder1); // Throws ElementNotFoundException before JENKINS-52164 fix anchor.click(); }
public void testTomcat() throws Exception { HtmlPage page = null; try { page = client.getPage(url); } catch (HttpHostConnectException e) { // sometimes on jenkins there are connections exceptions. // ignoring the rest of the test in this case LOG.error("Failed connecting to tomcat", e); return; } assertEquals("Content Repository Setup", page.getTitleText()); page = submitNewRepositoryForm(page); assertEquals("Content Repository Ready", page.getTitleText()); page = page.getAnchorByText("home").click(); assertEquals("Apache Jackrabbit JCR Server", page.getTitleText()); }
@Test @RunAsClient public final void testSatisfied() throws Exception { UserAgent ua = assertInitialPage(); HtmlPage page = ua.getHomePage(); // Script HtmlAnchor trigger = (HtmlAnchor)page.getElementById("trigger"); trigger.click(); List<String> alerts = ua.getAlerts(page); assertEquals(Arrays.asList("OK MEN"), alerts); // CSS DomNodeList<DomElement> links = page.getElementsByTagName("link"); assertEquals(1, links.size()); HtmlLink link = (HtmlLink)links.get(0); assertTrue(link.getHrefAttribute().endsWith("main.css")); } }
private void testSetDescription(String url, TestObject object) throws Exception { object.doSubmitDescription("description"); // test the roundtrip final WebClient wc = j.createWebClient(); HtmlPage page = wc.goTo(url); page.getAnchorByHref("editDescription").click(); wc.waitForBackgroundJavaScript(10000L); HtmlForm form = findForm(page, "submitDescription"); j.submit(form); assertEquals("description", object.getDescription()); }