List of usage examples for org.openqa.selenium By partialLinkText
public static By partialLinkText(String partialLinkText)
From source file:org.emonocot.portal.driver.PageObject.java
License:Open Source License
/** * @param text partial text of link to search for * @return false if there is a NoSuchElementException is thrown * true otherwise//from w w w.j a v a 2 s.c o m */ public final boolean isLinkPresent(String text) { try { webDriver.findElement(By.partialLinkText(text)); // if an element is found return true; } catch (NoSuchElementException e) { return false; } }
From source file:org.energyos.espi.common.test.BaseStepUtils.java
License:Apache License
public static void clickLinkByPartialText(String linkText) { WebElement link = driver.findElement(By.partialLinkText(linkText)); link.click(); }
From source file:org.fitting.selenium.SeleniumSelector.java
License:Apache License
/** * Create a selector for selecting elements based on a partial link text. * * @param partialLinkText The partial link text. * * @return The {@link org.fitting.selenium.SeleniumSelector} implementation. *//* w w w. j a v a 2 s . c om*/ public static SeleniumSelector byPartialLinkText(String partialLinkText) { return new SeleniumSelector(PARTIAL_LINK_TEXT, By.partialLinkText(partialLinkText)); }
From source file:org.glowroot.agent.webdriver.tests.BasicSmokeIT.java
License:Apache License
@Test public void shouldCheckTransactionPages() throws Exception { // given//from w w w . j av a 2 s . c o m App app = new App(driver, "http://localhost:" + getUiPort()); GlobalNavbar globalNavbar = new GlobalNavbar(driver); app.open(); // hitting F5 is just to test 304 responses Utils.withWait(driver, By.partialLinkText("Response time")).sendKeys(Keys.F5); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][contains(., '%')]")); driver.findElement(By.xpath("//button[@title='By percent of total time']")).click(); driver.findElement(By.linkText("By average time")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][contains(., 'ms')]")); driver.findElement(By.xpath("//button[@title='By average time']")).click(); driver.findElement(By.linkText("By throughput (per min)")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][contains(., '/min')]")); driver.findElement(By.xpath("//button[@title='By throughput (per min)']")).click(); driver.findElement(By.linkText("By percent of total time")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][contains(., '%')]")); Utils.withWait(driver, By.partialLinkText("percentiles")).click(); Utils.withWait(driver, By.partialLinkText("throughput")).click(); Utils.withWait(driver, By.partialLinkText("Slow traces")).click(); Utils.withWait(driver, By.partialLinkText("External queries")).click(); Utils.withWait(driver, By.partialLinkText("Continuous profiling")).click(); Utils.withWait(driver, By.xpath("//input[@ng-model='filter']")).sendKeys("JdbcServlet"); Utils.withWait(driver, By.xpath("//button[@ng-click='refreshButtonClick()']")).click(); new WebDriverWait(driver, 30).until( ExpectedConditions.textToBePresentInElementLocated(By.className("gt-profile"), "JdbcServlet")); Utils.withWait(driver, By.linkText("View flame graph (experimental)")).click(); // give flame graph a chance to render (only for visual when running locally) Thread.sleep(500); globalNavbar.getTransactionsLink().click(); Utils.withWait(driver, By.partialLinkText("/jdbcservlet")).click(); Utils.withWait(driver, By.partialLinkText("percentiles")).click(); Utils.withWait(driver, By.partialLinkText("Slow traces")).click(); Utils.withWait(driver, By.partialLinkText("External queries")).click(); Utils.withWait(driver, By.partialLinkText("Continuous profiling")).click(); Utils.withWait(driver, By.linkText("View flame graph (experimental)")).click(); }
From source file:org.glowroot.agent.webdriver.tests.BasicSmokeIT.java
License:Apache License
@Test public void shouldCheckErrorsPages() throws Exception { // given/*from ww w . ja v a2 s .c o m*/ App app = new App(driver, "http://localhost:" + getUiPort()); GlobalNavbar globalNavbar = new GlobalNavbar(driver); app.open(); globalNavbar.getErrorsLink().click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][not(contains(., '%'))]")); driver.findElement(By.xpath("//button[@title='By error count']")).click(); driver.findElement(By.linkText("By error rate")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][contains(., '%')]")); driver.findElement(By.xpath("//button[@title='By error rate']")).click(); driver.findElement(By.linkText("By error count")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Servlet Transactions'][not(contains(., '%'))]")); Utils.withWait(driver, By.xpath("//input[@ng-model='filter']")).sendKeys("xyz"); Utils.withWait(driver, By.xpath("//button[@ng-click='refreshButtonClick()']")).click(); Utils.withWait(driver, By.partialLinkText("Error traces")).click(); globalNavbar.getErrorsLink().click(); try { Utils.withWait(driver, By.partialLinkText("/errorservlet")).click(); } catch (StaleElementReferenceException e) { // this happens occassionally during travis-ci builds now that sidebar refresh is // delayed by 100 ms Utils.withWait(driver, By.partialLinkText("/errorservlet")).click(); } Utils.withWait(driver, By.partialLinkText("Error traces")).click(); }
From source file:org.glowroot.agent.webdriver.tests.NoTracesNoProfilesSmokeIT.java
License:Apache License
@Test public void shouldCheckTransactionPages() throws Exception { // given// w w w . j a v a 2 s .c o m App app = new App(driver, "http://localhost:" + getUiPort()); GlobalNavbar globalNavbar = new GlobalNavbar(driver); ConfigSidebar configSidebar = new ConfigSidebar(driver); StorageConfigPage storageConfigPage = new StorageConfigPage(driver); app.open(); globalNavbar.getConfigurationLink().click(); configSidebar.getStorageLink().click(); storageConfigPage.clickDeleteAllButton(); AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); Request request = asyncHttpClient .prepareGet("http://localhost:" + getUiPort() + "/backend/config/transaction?server-id=").build(); Response response = asyncHttpClient.executeRequest(request).get(); JsonNode responseNode = new ObjectMapper().readTree(response.getResponseBody()); String version = responseNode.get("version").asText(); request = asyncHttpClient.preparePost("http://localhost:" + getUiPort() + "/backend/config/transaction") .setBody("{\"serverId\":\"\",\"slowThresholdMillis\":" + Integer.MAX_VALUE + ",\"profilingIntervalMillis\":0,\"captureThreadStats\":false," + "\"version\":\"" + version + "\"}") .build(); int status = asyncHttpClient.executeRequest(request).get().getStatusCode(); asyncHttpClient.close(); if (status != 200) { throw new AssertionError("Unexpected status: " + status); } container.executeNoExpectedTrace(JdbcServlet.class); // give time for aggregates to be collected Thread.sleep(5000); // when app.open(); Utils.withWait(driver, By.linkText("Slow traces (0)")); Utils.withWait(driver, By.partialLinkText("/jdbcservlet")).click(); // give time for page to load and tab bar to refresh Thread.sleep(1000); globalNavbar.getErrorsLink().click(); Utils.withWait(driver, By.xpath("//a[normalize-space()='Error traces (0)']")); globalNavbar.getJvmLink().click(); // todo wait }
From source file:org.glowroot.tests.BasicSmokeIT.java
License:Apache License
@Test public void shouldCheckTransactionPages() throws Exception { App app = app();//w w w. j av a 2s. c o m GlobalNavbar globalNavbar = globalNavbar(); app.open(); // hitting F5 is just to test 304 responses Utils.withWait(driver, By.partialLinkText("Response time")).sendKeys(Keys.F5); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][contains(., '%')]")); driver.findElement(By.xpath("//button[@title='By percent of total time']")).click(); driver.findElement(By.linkText("By average time")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][contains(., 'ms')]")); driver.findElement(By.xpath("//button[@title='By average time']")).click(); driver.findElement(By.linkText("By throughput (per min)")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][contains(., '/min')]")); driver.findElement(By.xpath("//button[@title='By throughput (per min)']")).click(); driver.findElement(By.linkText("By percent of total time")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][contains(., '%')]")); Utils.withWait(driver, By.partialLinkText("percentiles")).click(); Utils.withWait(driver, By.partialLinkText("throughput")).click(); Utils.withWait(driver, By.partialLinkText("Slow traces")).click(); Utils.withWait(driver, By.partialLinkText("Queries")).click(); Utils.withWait(driver, By.partialLinkText("Continuous profiling")).click(); Utils.withWait(driver, By.xpath("//input[@ng-model='filter']")).sendKeys("JdbcServlet"); Utils.withWait(driver, By.xpath("//button[@ng-click='refresh()']")).click(); new WebDriverWait(driver, 30).until( ExpectedConditions.textToBePresentInElementLocated(By.className("gt-profile"), "JdbcServlet")); Utils.withWait(driver, By.linkText("View flame graph (experimental)")).click(); // give flame graph a chance to render (only for visual when running locally) Thread.sleep(1000); globalNavbar.getTransactionsLink().click(); Utils.withWait(driver, By.partialLinkText("/jdbcservlet")).click(); Utils.withWait(driver, By.partialLinkText("percentiles")).click(); Utils.withWait(driver, By.partialLinkText("Slow traces")).click(); Utils.withWait(driver, By.partialLinkText("Queries")).click(); Utils.withWait(driver, By.partialLinkText("Continuous profiling")).click(); Utils.withWait(driver, By.linkText("View flame graph (experimental)")).click(); }
From source file:org.glowroot.tests.BasicSmokeIT.java
License:Apache License
@Test public void shouldCheckNonActiveTraceModalPages() throws Exception { App app = app();//from w ww .j a v a 2 s . co m app.open(); Utils.withWait(driver, By.partialLinkText("Slow traces")).click(); String url = "http://localhost:" + getUiPort() + "/backend/transaction/points" + "?transaction-type=Web" + "&from=0" + "&to=" + Long.MAX_VALUE + "&headline-comparator=begins" + "&headline=" + "&error-message-comparator=begins" + "&error-message=" + "&user-comparator=begins" + "&user=" + "&attribute-name=" + "&attribute-value-comparator=begins" + "&attribute-value=" + "&limit=500" + "&agent-rollup-id=" + agentId; AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); Request request = asyncHttpClient.prepareGet(url).build(); Response response = asyncHttpClient.executeRequest(request).get(); JsonNode responseNode = new ObjectMapper().readTree(response.getResponseBody()); ArrayNode pointsNode = (ArrayNode) responseNode.get("normalPoints"); String traceId = ((ArrayNode) pointsNode.get(0)).get(3).asText(); if (WebDriverSetup.useCentral) { driver.get(app.getBaseUrl() + "/transaction/traces?agent-id=" + agentId + "&transaction-type=Web&modal-agent-id=" + agentId + "&modal-trace-id=" + traceId); } else { driver.get(app.getBaseUrl() + "/transaction/traces?transaction-type=Web&modal-trace-id=" + traceId); } asyncHttpClient.close(); clickAroundInTraceModal(traceId, false); }
From source file:org.glowroot.tests.BasicSmokeIT.java
License:Apache License
@Test public void shouldCheckErrorsPages() throws Exception { App app = app();/* www. ja v a 2 s .c o m*/ GlobalNavbar globalNavbar = globalNavbar(); app.open(); globalNavbar.getErrorsLink().click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][not(contains(., '%'))]")); driver.findElement(By.xpath("//button[@title='By error count']")).click(); driver.findElement(By.linkText("By error rate")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][contains(., '%')]")); driver.findElement(By.xpath("//button[@title='By error rate']")).click(); driver.findElement(By.linkText("By error count")).click(); Utils.withWait(driver, By.xpath("//a[@gt-display='All Web Transactions'][not(contains(., '%'))]")); Utils.withWait(driver, By.xpath("//input[@ng-model='filter']")).sendKeys("xyz"); Utils.withWait(driver, By.xpath("//button[@ng-click='refresh()']")).click(); Utils.withWait(driver, By.partialLinkText("Error traces")).click(); globalNavbar.getErrorsLink().click(); try { Utils.withWait(driver, By.partialLinkText("/errorservlet")).click(); } catch (StaleElementReferenceException e) { // this happens occassionally during travis-ci builds now that sidebar refresh is // delayed by 100 ms Utils.withWait(driver, By.partialLinkText("/errorservlet")).click(); } Utils.withWait(driver, By.partialLinkText("Error traces")).click(); }
From source file:org.glowroot.tests.NoTracesNoProfilesSmokeIT.java
License:Apache License
@Test public void shouldCheckTransactionPages() throws Exception { // this test doesn't work against the central ui because delete all button doesn't exist // which then means there may be old traces or old profiles found Assume.assumeFalse(WebDriverSetup.useCentral); // given/* ww w .ja v a 2s . c o m*/ App app = app(); GlobalNavbar globalNavbar = globalNavbar(); ConfigSidebar configSidebar = new ConfigSidebar(driver); StorageConfigPage storageConfigPage = new StorageConfigPage(driver); app.open(); globalNavbar.getAdminConfigLink().click(); configSidebar.getStorageLink().click(); storageConfigPage.clickDeleteAllButton(); AsyncHttpClient asyncHttpClient = new AsyncHttpClient(); Request request = asyncHttpClient .prepareGet("http://localhost:" + getUiPort() + "/backend/config/transaction?agent-id=" + agentId) .build(); Response response = asyncHttpClient.executeRequest(request).get(); JsonNode responseNode = new ObjectMapper().readTree(response.getResponseBody()); String version = responseNode.get("version").asText(); request = asyncHttpClient .preparePost("http://localhost:" + getUiPort() + "/backend/config/transaction?agent-id=" + agentId) .setBody("{\"slowThresholdMillis\":" + Integer.MAX_VALUE + ",\"profilingIntervalMillis\":0,\"captureThreadStats\":false," + "\"version\":\"" + version + "\"}") .build(); int statusCode = asyncHttpClient.executeRequest(request).get().getStatusCode(); asyncHttpClient.close(); if (statusCode != 200) { throw new AssertionError("Unexpected status code: " + statusCode); } container.executeNoExpectedTrace(JdbcServlet.class); // give time for aggregates to be collected Thread.sleep(5000); // when app.open(); Utils.withWait(driver, By.linkText("Slow traces (0)")); Utils.withWait(driver, By.partialLinkText("/jdbcservlet")).click(); // give time for page to load and tab bar to refresh Thread.sleep(1000); globalNavbar.getErrorsLink().click(); Utils.withWait(driver, By.xpath("//a[normalize-space()='Error traces (0)']")); globalNavbar.getJvmLink().click(); // todo wait }