List of usage examples for org.openqa.selenium By cssSelector
public static By cssSelector(String cssSelector)
From source file:com.cloudbees.workflow.ui.view.FailedJobTest.java
License:Open Source License
@Ignore("remove phantomjs: https://trello.com/c/JpUg8S5z/159-get-rid-of-phantomjs-webdriver") @Test/*from w w w . j a va 2 s . c o m*/ public void test() throws Exception { WebDriver webdriver = getWebDriver(); WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "Noddy Job"); job.setDefinition(new CpsFlowDefinition("" + "node {" + " stage ('Build'); " + " sh ('blah'); " + "}")); QueueTaskFuture<WorkflowRun> build = job.scheduleBuild2(0); jenkinsRule.assertBuildStatus(Result.FAILURE, build.get()); String jobUrl = getItemUrl(jenkinsRule.jenkins, job); webdriver.get(jobUrl); // Make sure the stage cell was marked as failed... List<WebElement> failedStageCells = webdriver .findElements(By.cssSelector(".stage-cell.FAILED .stage-wrapper")); Assert.assertEquals(1, failedStageCells.size()); // Make the sure the stage-failed-popover widget was added to the cell WebElement failedStageCell = failedStageCells.get(0); List<WebElement> stageFailedPopovers = failedStageCell .findElements(By.cssSelector(".stage-failed-popover")); Assert.assertEquals(1, stageFailedPopovers.size()); // Make sure that when we mouse over the failed stage cell we get a popup... moveMouseToElement(webdriver, failedStageCell); List<WebElement> popovers = waitForElementsAdded(webdriver, ".cbwf-popover"); // System.out.println(webdriver.getPageSource()); Assert.assertTrue(popovers.size() > 0); // Make sure the popover has what we expect... Assert.assertEquals("Failed with the following error(s)\n" + "Shell Script script returned exit code 127\n" + "See stage logs for more detail.\n" + "Logs", popovers.get(0).getText().trim()); // Make sure the popover is removed once we move off it //moveMouseOffElement(webdriver); //waitForElementsRemoved(webdriver, ".cbwf-popover"); }
From source file:com.cloudbees.workflow.ui.view.PausedJobTest.java
License:Open Source License
@Ignore("remove phantomjs: https://trello.com/c/JpUg8S5z/159-get-rid-of-phantomjs-webdriver") @Test// w w w . ja va 2 s .co m public void test() throws Exception { WebDriver webdriver = getWebDriver(); WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "Noddy Job"); job.setDefinition(new CpsFlowDefinition("" + "node {" + " stage ('Build'); " + " echo ('build'); " + " input (message: 'Is the build okay?'); " + "}")); QueueTaskFuture<WorkflowRun> q = job.scheduleBuild2(0); WorkflowRun b = q.getStartCondition().get(); CpsFlowExecution e = (CpsFlowExecution) b.getExecutionPromise().get(); while (b.getAction(InputAction.class) == null) { e.waitForSuspension(); } String jobUrl = getItemUrl(jenkinsRule.jenkins, job); webdriver.get(jobUrl); // Make sure the stage cell was marked as pending input... List<WebElement> pausedStageCells = webdriver .findElements(By.cssSelector(".stage-cell.PAUSED_PENDING_INPUT .stage-wrapper")); Assert.assertEquals(1, pausedStageCells.size()); // Move over the paused build and check for the popup... moveMouseToElement(webdriver, pausedStageCells.get(0)); List<WebElement> inputRequiredPopovers = waitForElementsAdded(webdriver, ".cbwf-popover .run-input-required"); Assert.assertEquals(1, inputRequiredPopovers.size()); // Check the popup content... WebElement inputRequiredPopover = inputRequiredPopovers.get(0); WebElement message = inputRequiredPopover.findElement(By.cssSelector(".message")); Assert.assertEquals("Is the build okay?", message.getText()); // Click on the proceed button WebElement proceedBtn = inputRequiredPopover.findElement(By.cssSelector(".action.proceed")); // clickOnElement(webdriver, proceedBtn); // // // Wait for the build to complete successfully // Util.waitForBuildCount(job, 1, Result.SUCCESS); // // // Click on the proceed button and wait for the popup to disappear // waitForElementsRemoved(webdriver, ".cbwf-popover .run-input-required"); }
From source file:com.cloudbees.workflow.ui.view.StagePopupsTest.java
License:Open Source License
@Ignore("remove phantomjs: https://trello.com/c/JpUg8S5z/159-get-rid-of-phantomjs-webdriver") @Test//from w ww . j a v a2 s . c om public void test() throws Exception { WebDriver webdriver = getWebDriver(); WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "Noddy Job"); job.setDefinition(new CpsFlowDefinition( "" + "node {" + " stage ('Build'); " + " sh ('ls'); " + " sh ('blah'); " + "}")); QueueTaskFuture<WorkflowRun> build = job.scheduleBuild2(0); jenkinsRule.assertBuildStatus(Result.FAILURE, build.get()); String jobUrl = getItemUrl(jenkinsRule.jenkins, job); webdriver.get(jobUrl); // Make sure the stage cell was marked as failed... List<WebElement> failedStageCells = webdriver .findElements(By.cssSelector(".stage-cell.FAILED .stage-wrapper")); Assert.assertEquals(1, failedStageCells.size()); // Make the sure the stage-failed-popover widget was added to the cell WebElement failedStageCell = failedStageCells.get(0); List<WebElement> stageFailedPopovers = failedStageCell .findElements(By.cssSelector(".stage-failed-popover")); Assert.assertEquals(1, stageFailedPopovers.size()); // Make sure that when we mouse over the failed stage cell we get a popup... moveMouseToElement(webdriver, failedStageCell); List<WebElement> popovers = waitForElementsAdded(webdriver, ".cbwf-popover"); Assert.assertTrue(popovers.size() > 0); Assert.assertEquals("Failed with the following error(s)\n" + "Shell Script script returned exit code 127\n" + "See stage logs for more detail.\n" + "Logs", popovers.get(0).getText().trim()); }
From source file:com.cloudbees.workflow.ui.view.WorkflowStageViewActionTest.java
License:Open Source License
@Ignore("remove phantomjs: https://trello.com/c/JpUg8S5z/159-get-rid-of-phantomjs-webdriver") @Test/*from w w w.j a v a2 s . co m*/ public void test() throws Exception { WebDriver webdriver = getWebDriver(); WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "Noddy Job"); job.setDefinition(new CpsFlowDefinition("" + "node {" + " stage ('Build'); " + " sh ('echo Building'); " + " stage ('Test'); " + " sh ('echo Testing'); " + " stage ('Deploy'); " + " sh ('echo Deploying'); " + "}")); QueueTaskFuture<WorkflowRun> build = job.scheduleBuild2(0); jenkinsRule.assertBuildStatusSuccess(build); String jobUrl = getItemUrl(jenkinsRule.jenkins, job); webdriver.get(jobUrl); // System.out.println(webdriver.getPageSource()); // Make sure the jobsTable is rendered in the page WebElement jobsTable = webdriver.findElement(By.className("jobsTable")); Assert.assertNotNull(jobsTable); // Check the totals are rendered // List<WebElement> stageWrappers = jobsTable.findElements(By.cssSelector(".totals .stage-wrapper")); // Assert.assertEquals(3, stageWrappers.size()); // Should have just one job List<WebElement> jobs = jobsTable.findElements(By.cssSelector(".job")); Assert.assertEquals(1, jobs.size()); // That job should have 3 stages List<WebElement> jobStages = jobs.get(0).findElements(By.cssSelector(".stage-wrapper")); Assert.assertEquals(3, jobStages.size()); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Attribute.//w ww . j av a2 s. c o m * * @param tagname the tagname * @param value the value * @return the by */ public static By attribute(final String tagname, final String value) { return By.cssSelector("[" + tagname + "=\"" + value + "\"]"); }
From source file:com.cognifide.aet.job.common.modifiers.hide.HideModifierTest.java
License:Apache License
@Test public void hideElement_ValidCssIsProvided_WebDriverFindElementsMethodIsCalledOnce() throws ProcessingException, ParametersException { when(params.containsKey(PARAM_CSS)).thenReturn(true); when(params.get(PARAM_CSS)).thenReturn(PARAM_CSS_VALUE); tested.setParameters(params);//w w w . j a v a 2 s. c o m tested.collect(); verify(webDriver, atLeast(1)).findElement(By.cssSelector(PARAM_CSS_VALUE)); }
From source file:com.cognifide.aet.job.common.modifiers.replacetext.ReplaceTextModifierTest.java
License:Apache License
@Test public void ReplaceTextInElement_ValidCssIsProvided_WebDriverFindElementsMethodIsCalledOnce() throws ProcessingException, ParametersException { when(params.containsKey(PARAM_CSS)).thenReturn(true); when(params.get(PARAM_CSS)).thenReturn(PARAM_CSS_VALUE); tested.setParameters(params);//from w w w. j a v a 2 s .com tested.collect(); verify(webDriver, atLeast(1)).findElement(By.cssSelector(PARAM_CSS_VALUE)); }
From source file:com.cognifide.aet.job.common.modifiers.WebElementsLocatorParams.java
License:Apache License
protected void setElementParams(Map<String, String> params) throws ParametersException { String xpath = params.get(XPATH_PARAM); String css = params.get(CSS_PARAM); if (StringUtils.isBlank(xpath) == StringUtils.isBlank(css)) { throw new ParametersException( "Either 'xpath' or 'css' parameter must be provided for element modifier."); }/*from w w w .j av a 2 s .co m*/ locator = StringUtils.isNotBlank(xpath) ? By.xpath(xpath) : By.cssSelector(css); initializeTimeOutParam(params.get(PARAM_TIMEOUT)); }
From source file:com.cognifide.aet.sanity.functional.po.ReportHomePage.java
License:Apache License
public void openAndWaitForTiles() { webDriver.get(reportUrl);/*from ww w . jav a 2 s .co m*/ Integer tiles = bobcatWait.withTimeout(Timeouts.BIG) .until(new LoadedCondition(By.cssSelector(TILE_SELECTOR))); LOG.debug("tiles for URLs found: '{}'", tiles); }
From source file:com.cognifide.aet.sanity.functional.po.ReportHomePage.java
License:Apache License
public List<WebElement> findTiles() { return webDriver.findElements(By.cssSelector(TILE_SELECTOR)); }