List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:com.ts.commons.TSPageFactory.TSAnnotations.java
License:Apache License
protected By buildByFromShortFindBy(FindBy findBy) { if (!"".equals(findBy.className())) return (By) By.className(findBy.className()); if (!"".equals(findBy.css())) return (By) By.cssSelector(findBy.css()); if (!"".equals(findBy.id())) return (By) By.id(findBy.id()); if (!"".equals(findBy.linkText())) return (By) By.linkText(findBy.linkText()); if (!"".equals(findBy.name())) return (By) By.name(findBy.name()); if (!"".equals(findBy.partialLinkText())) return (By) By.partialLinkText(findBy.partialLinkText()); if (!"".equals(findBy.tagName())) return (By) By.tagName(findBy.tagName()); if (!"".equals(findBy.xpath())) return (By) By.xpath(findBy.xpath()); // Fall through return null;// ww w. j ava2 s.c o m }
From source file:com.ttdev.wicketpagetest.sample.spring.AjaxPageTest.java
License:Open Source License
public void testEasyWaitingForAjax() { MockableSpringBeanInjector.mockBean("service", new CalcService() { public int calcNext(int current) { return current + 1; }/*from ww w .j a va2 s .c om*/ }); WicketSelenium ws = WebPageTestContext.getWicketSelenium(); ws.openBookmarkablePage(AjaxPage.class); ws.subscribeAjaxDoneHandler(); WebElement output = ws.findElement(By.id("output")); assert output.getText().equals("Current: 0"); ws.findElement(By.linkText("Calculate next")).click(); ws.waitUntilAjaxDone(); assert output.getText().equals("Current: 1"); ws.findElement(By.linkText("Calculate next")).click(); ws.waitUntilAjaxDone(); assert output.getText().equals("Current: 2"); }
From source file:com.urlisit.siteswrapper.srs.gae.SitesWrapper_GAE_1.java
License:Apache License
@Test public void testSitesWrapper_GAE_1() throws Exception { driver.get(baseUrl/* w w w . ja v a 2s .c o m*/ + "/ServiceLogin?service=ah&passive=true&continue=https%3A%2F%2Fappengine.google.com%2F_ah%2Fconflogin%3Fcontinue%3Dhttps%3A%2F%2Fappengine.google.com%2Fdatastore%2Fexplorer%253F%2526app_id%253Ds%7Esiteswrapper<mpl=ae"); driver.findElement(By.id("Email")).clear(); driver.findElement(By.id("Email")).sendKeys(SitesWrapper.ADMINISTRATOR_EMAIL); driver.findElement(By.id("Passwd")).clear(); driver.findElement(By.id("Passwd")).sendKeys(SitesWrapper.getAdministratorPasswd()); driver.findElement(By.id("signIn")).click(); new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Site"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue( closeAlertAndGetItsText().matches("^Are you sure you want to delete the selected items[\\s\\S]$")); new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Style"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue( closeAlertAndGetItsText().matches("^Are you sure you want to delete the selected items[\\s\\S]$")); new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Landing"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue( closeAlertAndGetItsText().matches("^Are you sure you want to delete the selected items[\\s\\S]$")); new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Item"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue( closeAlertAndGetItsText().matches("^Are you sure you want to delete the selected items[\\s\\S]$")); new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Page"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue( closeAlertAndGetItsText().matches("^Are you sure you want to delete the selected items[\\s\\S]$")); new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("DocumentId"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue( closeAlertAndGetItsText().matches("^Are you sure you want to delete the selected items[\\s\\S]$")); driver.findElement(By.linkText("Sign out")).click(); }
From source file:com.urlisit.siteswrapper.srs.gas.SitesWrapper_GAS_1.java
License:Apache License
/** * Precondition//from w w w . j a v a 2s .co m * * This Test Script requires that: * <ul> * <li>SitesWrapper-GAE-GWT is installed in (i.e.; deployed to) Google App Engine * as an application administered by the same Google account as the primary actor, * but not yet configured in either the Configuration Client or the datastore. * <li>The primary actor knows the application id of the application in Google App * Engine. * <li>The primary actor is currently logged in (authenticated) to their Google Account. * <li><bold>Note</bold> - In the case that SitesWrapper has already been installed and * configured, the Entities in the datastore must be dropped and the configuration * sheets in the Configuration Client spreadsheet deleted in order to execute this * Test Script. * </ul> * * @throws Exception */ @Before public void precondition() throws Exception { /* * Determine if SitesWrapper has been installed and configured using the * same technique as the Configuration Client by executing an HTTP POST * against /isInitialized in the Server Service Wrapper which will return * 202 if the client has been bound to the server. If it has, the sheets * in the spreadsheet need to be deleted along with the ConfigurationId, * Site, Style, Item, Landing and Page objects in the datastore. */ URL isInitialized = new URL(SitesWrapper.SITESWRAPPER_PRODUCTION_URL + "isInitialized"); HttpURLConnection connection = (HttpURLConnection) isInitialized.openConnection(); connection.setRequestMethod("POST"); connection.setDoOutput(true); DataOutputStream output = new DataOutputStream(connection.getOutputStream()); output.writeBytes(""); output.flush(); output.close(); int isInstalled = connection.getResponseCode(); connection.disconnect(); if (isInstalled == 202) { /* * SitesWrapper has been bound and configured. */ startDriver(); /* * Log into the datastore viewer */ //driver.get(baseUrl + "/ServiceLogin?service=ah&passive=true&continue=https%3A%2F%2Fappengine.google.com%2F_ah%2Fconflogin%3Fcontinue%3Dhttps%3A%2F%2Fappengine.google.com%2Fdatastore%2Fexplorer%253F%2526app_id%253Ds%7Esiteswrapper<mpl=ae"); driver.get(baseUrl + SitesWrapper.DATASTORE_VIEWER_LOGIN_URI); driver.findElement(By.id("Email")).clear(); driver.findElement(By.id("Email")).sendKeys(SitesWrapper.ADMINISTRATOR_EMAIL); driver.findElement(By.id("Passwd")).clear(); driver.findElement(By.id("Passwd")).sendKeys(SitesWrapper.getAdministratorPasswd()); driver.findElement(By.id("signIn")).click(); /* * Delete the Site object */ new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Site"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue(closeAlertAndGetItsText() .matches("^Are you sure you want to delete the selected items[\\s\\S]$")); /* * Delete the Style collection */ new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Style"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue(closeAlertAndGetItsText() .matches("^Are you sure you want to delete the selected items[\\s\\S]$")); /* * Delete the Item collection */ new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Item"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue(closeAlertAndGetItsText() .matches("^Are you sure you want to delete the selected items[\\s\\S]$")); /* * Delete the Landing collection */ new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Landing"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue(closeAlertAndGetItsText() .matches("^Are you sure you want to delete the selected items[\\s\\S]$")); /* * Delete the Page collection */ new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("Page"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue(closeAlertAndGetItsText() .matches("^Are you sure you want to delete the selected items[\\s\\S]$")); /* * Delete the DocumentId object */ new Select(driver.findElement(By.id("ae-datastore-explorer-kind"))).selectByVisibleText("DocumentId"); driver.findElement(By.cssSelector("th.cbc.tct-selectall > input[type=\"checkbox\"]")).click(); driver.findElement(By.id("ae-datastore-explorer-delete")).click(); assertTrue(closeAlertAndGetItsText() .matches("^Are you sure you want to delete the selected items[\\s\\S]$")); driver.findElement(By.linkText("Sign out")).click(); driver.close(); /* * Delete the sheets in the spreadsheet by first adding an empty sheet * and then selecting and deleting each sheet sequentially beginning * with the first sheet but leaving the last empty sheet untouched. * Delete the sheets in the spreadsheet logging in to Google Docs as the * Administrator and accessing the spreadsheet. Click the QASE Automated * Test Scripts link and select SitesWrapper_GAS_1, which is a helper * script which deletes all the sheets in the spreadsheet leaving one * empty sheet, which is equivalent to the Apps Script Configuration * Clients newly installed but yet to be bound and configured state. */ startDriver(); /* * Login to Google Docs */ //driver.get(baseUrl + "/ServiceLogin?continue=https%3A%2F%2Fdocs.google.com%2Fa%2Furlisit.com%2Fspreadsheets%2Fd%2F1HG6P-MswtJoXPSKhIhi0xl8gUGm5Whh-oivVNb9zd_s%2Fedit<mpl=sheets&service=wise&sacu=1&hd=urlisit.com"); driver.get(baseUrl + SitesWrapper.APPS_SCRIPT_CONFIGURATION_CLIENT_LOGIN_URI); driver.findElement(By.id("Email")).clear(); driver.findElement(By.id("Email")).sendKeys(SitesWrapper.ADMINISTRATOR_EMAIL); driver.findElement(By.id("Passwd")).clear(); driver.findElement(By.id("Passwd")).sendKeys(SitesWrapper.getAdministratorPasswd()); driver.findElement(By.id("signIn")).click(); /* * Switch the selenium context to the sidebar menu */ driver.switchTo().frame(driver.findElement(By.cssSelector( "html body div.script-application-sidebar div.script-application-sidebar-content iframe"))); driver.switchTo().frame(driver.findElement(By.id("script_frame"))); /* * Click Automated Test Utilities */ driver.findElement(By.id("automatedTestScripts-caja-guest-0___")).click(); /* * Click SitesWrapper_GAS_1 */ driver.switchTo().defaultContent(); driver.switchTo().frame(driver.findElement(By.cssSelector( "html body div.script-application-sidebar div.script-application-sidebar-content iframe"))); driver.switchTo().frame(driver.findElement(By.id("script_frame"))); driver.findElement(By.id("SitesWrapper_GAS_1-caja-guest-0___")).click(); /* * Assert Test PASSED */ driver.switchTo().defaultContent(); driver.switchTo().frame(driver.findElement(By.cssSelector( "html body div.script-application-sidebar div.script-application-sidebar-content iframe"))); driver.switchTo().frame(driver.findElement(By.id("script_frame"))); assertEquals("PASSED", driver.findElement(By.id("PASSED-caja-guest-0___")).getText()); /* * Click Return */ //driver.switchTo().frame(driver.findElement(By.cssSelector("html body div.script-application-sidebar div.script-application-sidebar-content iframe"))); //driver.switchTo().frame(driver.findElement(By.id("script_frame"))); driver.findElement(By.id("return-caja-guest-0___")).click(); /* * Logout of Google Docs */ driver.close(); } /* * SitesWrapper is ready to be initialized and the default configuration * updated in the datastore. */ }
From source file:com.vaadin.tests.integration.WebSpherePortalIntegrationTest.java
License:Apache License
private boolean isLoggedIn() { return driver.findElements(By.linkText("Log Out")).size() == 1; }
From source file:com.vaadin.tests.integration.WebSpherePortalIntegrationTest.java
License:Apache License
private void login() { driver.findElement(By.linkText("Log In")).click(); driver.findElement(By.id("userID")).sendKeys("test"); driver.findElement(By.id("password")).sendKeys("testtest"); hitButton("login.button.login"); }
From source file:com.vaadin.tests.integration.WebSpherePortalIntegrationTest.java
License:Apache License
@Test public void viewModeIsSetToEdit() throws IOException { driver.findElement(By.linkText("Edit")).click(); assertThat(driver.findElement(By.tagName("input")).isEnabled(), is(true)); }
From source file:com.virtusa.isq.vtaf.runtime.SeleniumTestBase.java
License:Apache License
/** * Gets the locator type.//from w w w . ja v a 2s . c o m * * @param objectID * the object id * @return the locator type * @throws Exception * the exception */ public final By getLocatorType(final String objectID) throws Exception { String typeString = ""; String ref = ""; String objectIDinLowerCase = objectID.toLowerCase(Locale.getDefault()); boolean isObjectTypeisXpath = objectIDinLowerCase.startsWith("/"); if (!isObjectTypeisXpath) { try { typeString = objectIDinLowerCase.substring(0, objectID.indexOf('=')); ref = objectID.substring(objectID.indexOf('=') + 1, objectID.length()); } catch (Exception e) { throw new Exception("Invalid Locator Passed " + objectID); } } // String objectIDType = typeString.toLowerCase(Locale.getDefault()); if (isObjectTypeisXpath) { return By.xpath(objectID); } else if (typeString.contains("xpath")) { return By.xpath(ref); } else if (typeString.contains("css")) { return By.cssSelector(ref); } else if (typeString.contains("id")) { return By.id(ref); } else if (typeString.contains("link")) { return By.linkText(ref); } else if (typeString.contains("tagname")) { return By.tagName(ref); } else if (typeString.contains("name")) { return By.name(ref); } else if (typeString.contains("classname")) { return By.className(ref); } throw new Exception("Invalid Locator Type Passed " + ref); }
From source file:com.vmware.gemfire.tools.pulse.testbed.driver.PulseUITest.java
License:Apache License
private void searchByLinkAndClick(String linkText) { WebElement dataViewButton = By.linkText(linkText).findElement(driver); assertNotNull(dataViewButton); dataViewButton.click(); }
From source file:com.vmware.gemfire.tools.pulse.testbed.driver.PulseUITest.java
License:Apache License
@Test public void testMemberViewRegions() { searchByLinkAndClick(DATA_VIEW_LABEL); waitForElementByClassName("pointDetailsPadding", 10); searchByXPathAndClick("//div[@title='peer1']"); waitForElementById("memberRegionsCount", 10); List<Server> servers = testBed.getRootDs().getServers(); List<Locator> locators = testBed.getRootDs().getLocators(); List<Peer> peers = testBed.getRootDs().getPeers(); String prevSelectedMember = "peer1"; for (Peer p : peers) { String peer = p.getName(); System.out.println("Checking regions mapping for member " + peer); WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember)); comboBox.click();/*ww w . j a v a 2 s. com*/ WebElement comboList = driver.findElement(By.id("clusterMembersContainer")); WebElement selectedMember = comboList.findElement(By.linkText(peer)); selectedMember.click(); timeout(); String peername = driver.findElement(By.id("memberName")).getText(); List<Region> peerRegionscount = testBed.getRootDs().getRegions(peer); int peerRegions = Integer.parseInt(driver.findElement(By.id("memberRegionsCount")).getText()); assertEquals(peerRegionscount.size(), peerRegions); prevSelectedMember = peername; } for (Server s : servers) { String server = s.getName(); System.out.println("Checking regions mapping for server " + server); WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember)); comboBox.click(); WebElement comboList = driver.findElement(By.id("clusterMembersContainer")); WebElement selectedMember = comboList.findElement(By.linkText(server)); selectedMember.click(); timeout(); String peername = driver.findElement(By.id("memberName")).getText(); List<Region> serverRegionscount = testBed.getRootDs().getRegions(server); int serverRegions = Integer.parseInt(driver.findElement(By.id("memberRegionsCount")).getText()); assertEquals(serverRegionscount.size(), serverRegions); prevSelectedMember = peername; } /* for (Locator l : locators) { String locator = l.getName(); System.out.println("Checking regions mapping for locator " + locator); WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember)); comboBox.click(); WebElement comboList = driver.findElement(By.id("clusterMembersContainer")); WebElement selectedMember = comboList.findElement(By.linkText(locator)); selectedMember.click(); timeout(); String peername = driver.findElement(By.id("memberName")).getText(); List<Region> locatorRegionscount = testBed.getRootDs().getRegions(locator); int locatorRegions = Integer.parseInt(driver.findElement( By.id("memberRegionsCount")).getText()); assertIndexDetailsEquals(locatorRegionscount.size(), locatorRegions); prevSelectedMember = peername; }*/ }