List of usage examples for org.openqa.selenium WebElement isDisplayed
boolean isDisplayed();
From source file:com.consensus.qa.verizon.tests.ReturnTests.java
private String poaCompleteFlow_QA70(DependantTestCaseInputs dependantValues) throws IOException { //Login to retail page. PageBase.LoginPageRetail().poaLogin(Utilities.getCredentials("tuserUN"), Utilities.getCredentials("tuserPwd"), Utilities.getCredentials("storeId0003")); PageBase.HomePageRetail().guestLookupTab.click(); PageBase.CustomerLookupPage().receiptIdTextbox.sendKeys(dependantValues.RECEIPT_ID); Reporter.log(dependantValues.RECEIPT_ID); java.util.List<WebElement> SubmitButtons = driver.findElements(By.xpath(ControlLocators.SUBMIT_RECEIPTID)); for (WebElement visibleSubmitButton : SubmitButtons) { if (visibleSubmitButton.isDisplayed()) { visibleSubmitButton.click(); break; }/*from www . j a va2 s.com*/ } PageBase.CarrierCreditCheckPage().firstNameTextBox.sendKeys(dependantValues.FIRST_NAME); PageBase.CarrierCreditCheckPage().lastNameTextBox.sendKeys(dependantValues.LAST_NAME); Reporter.log("<br>First Name: " + dependantValues.FIRST_NAME); Reporter.log(" Last Name: " + dependantValues.LAST_NAME + "; "); ExchangeTests.SelectLicense(dependantValues.ID_TYPE.toString(), PageBase.ReturnOrExchangeVerificationPage().idTypeDropdown); Reporter.log("State: " + dependantValues.STATE + "; "); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().stateDropdown, Utilities.SelectDropMethod.SELECTBYTEXT, dependantValues.STATE); Reporter.log("ID Type: " + dependantValues.ID_TYPE + "; "); PageBase.ReturnOrExchangeVerificationPage().idNumberTextbox.sendKeys(dependantValues.ID_NUMBER); Reporter.log("ID Number: " + dependantValues.ID_NUMBER + "."); PageBase.CommonControls().continueCommonButton.click(); Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox); PageBase.ReturnScanDevicePage().esnIemeidTextbox.click(); PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear(); PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI1); PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click(); PageBase.ReturnOrExhangePreConditions().SelectPreconditions(); PageBase.ReturnOrExhangePreConditions().continueREVButton.click(); PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click(); PageBase.ReturnOrExchangeVerificationPage().returnDEVICE.click(); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().returnReasons, SelectDropMethod.SELECTBYINDEX, "1"); PageBase.CustomerLookupPage().continueButton.click(); if (driver.getCurrentUrl().contains("passwordcapture")) { PageBase.VerizonAccountPassword().password.sendKeys("Hello"); PageBase.VerizonAccountPassword().continueButton.click(); } else if (driver.getCurrentUrl().contains("printticket")) { PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click(); } Assert.assertTrue(driver.findElement(By.xpath("//h2[contains(text(), 'Support Center')]")).isDisplayed()); // Commenting below Assertions as this doesn't show up in Carrier Responder if (driver.getCurrentUrl().contains("passwordcapture")) { PageBase.VerizonAccountPassword().password.sendKeys("Hello"); PageBase.VerizonAccountPassword().continueButton.click(); } //*PageBase.CommonControls().continueButton.click(); // RMSS Assertions - Todo from Parent Order /*Assert.assertEquals(PageBase.PrintMobileScanSheetPage().phonePriceValuePMSSText.getText(), ""); Assert.assertEquals(PageBase.PrintMobileScanSheetPage().phoneTaxValuePMSSText.getText(), ""); PageBase.PrintMobileScanSheetPage().barcodePMSSImage.isDisplayed(); PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click(); Assert.assertTrue(PageBase.ReturnConfirmation().returnConfirmation.isDisplayed()); Assert.assertTrue(PageBase.ReturnConfirmation().successfullyReturnedString.isDisplayed()); Assert.assertTrue(PageBase.ReturnConfirmation().linePhonenoString.isDisplayed()); Assert.assertTrue(PageBase.ReturnConfirmation().returnStep1Text.isDisplayed()); Assert.assertTrue(PageBase.ReturnConfirmation().returnStep2Text.isDisplayed()); Assert.assertTrue(PageBase.ReturnConfirmation().printInstruction.isDisplayed()); Assert.assertTrue(PageBase.ReturnConfirmation().returnHome.isDisplayed());*/ return orderId; }
From source file:com.consensus.test.verizon.tests.ExchangeTests.java
@Test(groups = { "verizon" }) @Parameters("test-type") public void QA_51_VerizonNonEdgeExchangeLikeForUnlike(@Optional String testtype) throws IOException, InterruptedException, AWTException { DependantTestCaseInputs dependantValues = Utilities.ReadFromCSV("QA_50"); if (dependantValues.TC_ID == "" || dependantValues.ORDER_ID == "") { AddNewLineTests addNewLine = new AddNewLineTests(); addNewLine.QA50_VerizonNonEdgeWithNumberPortCCInCA(BrowserSettings.readConfig("test-type")); dependantValues = Utilities.ReadFromCSV("QA_50"); if (dependantValues.TC_ID == "" || dependantValues.ORDER_ID == "") { Reporter.log("<br> Data is not available from QA_50"); Assert.fail("Data is not available from QA_50"); }//from w w w. j a va 2 s .c o m } String ChildOrderId = null; String newIMEI1 = PageBase.CSVOperations() .GetIMEIOrSimNumberOrReceiptId(FileName.SamsungGalaxyS4_16GBWhite); String newIMEI2 = PageBase.CSVOperations() .GetIMEIOrSimNumberOrReceiptId(FileName.SamsungGalaxyS4_16GBWhite); String simType1 = PageBase.CSVOperations().GetIMEIOrSimNumberOrReceiptId(FileName.Sim_3FF); String simType2 = PageBase.CSVOperations().GetIMEIOrSimNumberOrReceiptId(FileName.Sim_3FF); String testType = BrowserSettings.readConfig("test-type"); Reporter.log("QA_51_VerizonNonEdgeLikeForUnlike Starts."); Reporter.log("<br>Launching Browser"); Log.startTestCase("QA_51_VerizonNonEdgeExchange_LikeForUnlike"); if (testType.equals("internal")) { AdminBaseClass adminBaseClass = new AdminBaseClass(); adminBaseClass.launchAdminInNewTab(); PageBase.AdminPage().navigateToSimulator(); if (readConfig("internalTestType").toLowerCase().equals("carrierresponder")) { Reporter.log("Using Carrier Responder <br> <p>", true); PageBase.AdminPage().selectWebAPIResponse("Verizon", "CarrierResponder"); PageBase.AdminPage().selectAPIConfig("Verizon"); Utilities.waitForElementVisible(PageBase.CarrierResponseXMLPage().verizonCarrierTab); PageBase.CarrierResponseXMLPage().verizonCarrierTab.click(); Utilities.waitForElementVisible(PageBase.CarrierResponseXMLPage().versionsDropdown); PageBase.CarrierResponseXMLPage().selectOptions("current", "returnOrExchangeDevice", "default_exchange.xml"); Reporter.log("<br>XML Used: returnOrExchangeDevice - default_exchange.xml", true); Utilities.waitForElementVisible(PageBase.CarrierResponseXMLPage().saveResponseButton); PageBase.CarrierResponseXMLPage().saveResponseButton.click(); Reporter.log("<br>Carrier Responder Changes Done!!!", true); } } else //External { AdminBaseClass adminBaseClass = new AdminBaseClass(); adminBaseClass.launchAdminInNewTab(); PageBase.AdminPage().navigateToSimulator(); PageBase.AdminPage().selectWebAPIResponse("Verizon", "External"); Reporter.log("<br><U>Pointing to External Server</U>"); } String receiptId = dependantValues.RECEIPT_ID; Utilities.switchPreviousTab(); //Calling DBError utility to find initial count or error in log files. DBError.navigateDBErrorPage(); int initialCount = PageBase.AdminPage().totalErrorCount(); Utilities.switchPreviousTab(); PageBase.LoginPageRetail().poaLogin(Utilities.getCredentials("tuserUN"), Utilities.getCredentials("tuserPwd"), Utilities.getCredentials("storeId0003")); Reporter.log("Returning the device using Receipt ID: "); PageBase.HomePageRetail().newGuestButton.click(); PageBase.HomePageRetail().guestLookupTab.click(); PageBase.CustomerLookupPage().receiptIdTextbox.sendKeys(receiptId); Reporter.log(receiptId); List<WebElement> SubmitButtons = driver.findElements(By.xpath(ControlLocators.SUBMIT_RECEIPTID)); for (WebElement visibleSubmitButton : SubmitButtons) { if (visibleSubmitButton.isDisplayed()) { visibleSubmitButton.click(); break; } } PageBase.CarrierCreditCheckPage().firstNameTextBox.sendKeys(dependantValues.FIRST_NAME); PageBase.CarrierCreditCheckPage().lastNameTextBox.sendKeys(dependantValues.LAST_NAME); Reporter.log("<br>First Name: " + dependantValues.FIRST_NAME); Reporter.log(" Last Name: " + dependantValues.LAST_NAME + "; "); SelectLicense(dependantValues.ID_TYPE, PageBase.ReturnOrExchangeVerificationPage().idTypeDropdown); Reporter.log("State: " + dependantValues.STATE + "; "); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().stateDropdown, SelectDropMethod.SELECTBYTEXT, dependantValues.STATE); Reporter.log("ID Type: " + dependantValues.ID_TYPE + "; "); PageBase.ReturnOrExchangeVerificationPage().idNumberTextbox.sendKeys(dependantValues.ID_NUMBER); Reporter.log("ID Number: " + dependantValues.ID_NUMBER + "."); PageBase.CommonControls().continueCommonButton.click(); Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox); PageBase.ReturnScanDevicePage().esnIemeidTextbox.click(); PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear(); PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI1); PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click(); SelectPreConditions(); Reporter.log("<br>Pre Conditions Set for First Device"); PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click(); PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click(); PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click(); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn, SelectDropMethod.SELECTBYINDEX, "2"); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons, SelectDropMethod.SELECTBYINDEX, "1"); WebElement newESNBox = driver.findElement(By.id("addDeviceId")); newESNBox.click(); newESNBox.clear(); newESNBox.sendKeys(newIMEI1); PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click(); Thread.sleep(2000); Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons, SelectDropMethod.SELECTBYINDEX, "1"); Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().returnAnotherDevice); PageBase.ReturnOrExchangeVerificationPage().returnAnotherDevice.click(); Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox); PageBase.ReturnScanDevicePage().esnIemeidTextbox.click(); PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear(); PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI2); PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click(); SelectPreConditions(); Reporter.log("<br>Pre Conditions Set for Second Device"); PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click(); PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click(); PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click(); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn, SelectDropMethod.SELECTBYINDEX, "2"); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons, SelectDropMethod.SELECTBYINDEX, "1"); newESNBox = driver.findElement(By.id("addDeviceId")); newESNBox.click(); newESNBox.clear(); newESNBox.sendKeys(newIMEI2); PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click(); Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons, SelectDropMethod.SELECTBYINDEX, "1"); PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click(); PageBase.VerizonSelectPlanFeaturesPage().continueSPFButton.click();//driver.findElement(By.id("featureSubmit")).click(); Thread.sleep(1000); Utilities.ScrollToElement(PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance); Thread.sleep(500); PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance.click(); PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance.click(); Thread.sleep(500); PageBase.ReturnOrExchangeVerificationPage().secondDeviceNoInsurance.click(); PageBase.ReturnOrExchangeVerificationPage().secondDeviceNoInsurance.click(); driver.findElement(By.xpath(".//*[@id='guestReview']/div/div/label/span")).click(); PageBase.CommonControls().continueButton.click(); Utilities.waitForElementVisible(PageBase.CommonControls().continueCommonButton); Utilities.ScrollToElement(PageBase.CommonControls().continueCommonButton); if (BrowserSettings.readConfig("Activation") == "true") { PageBase.CommonControls().continueCommonButton.click(); if (driver.getCurrentUrl().contains("payment")) { PageBase.PaymentRequiredPage().populatingCardDetailsPaymentRequired(CardType.VISA); Utilities.ClickElement(PageBase.PaymentRequiredPage().sameAddressTab); Utilities.ClickElement(PageBase.PaymentRequiredPage().continuePRButton); } ChildOrderId = PageBase.PrintMobileScanSheetPage().orderNumberValuePMSSText.getText(); Reporter.log("Child Order Created!!! <br> <p>" + ChildOrderId); PageBase.ReturnOrExchangeVerificationPage().continueExchangeMSSPage.click(); PageBase.ReturnOrExchangeVerificationPage().continueExchangeMSSPage.click(); Utilities.implicitWaitSleep(1000); PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click(); PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click(); PageBase.PaymentVerificationPage().textboxTargetReceiptID.sendKeys(receiptId); PageBase.PaymentVerificationPage().submitButton.click(); Reporter.log("Re-check Receipt ID - Successful <br> <p>"); Utilities.waitForElementVisible(PageBase.DeviceVerificationaandActivation().deviceIMEITextbox); PageBase.DeviceVerificationaandActivation().deviceIMEITextbox.sendKeys(newIMEI1); PageBase.DeviceVerificationaandActivation().submitDVAButton.click(); driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI1)).click(); driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI1)) .sendKeys(simType1); Utilities.ScrollToElement(PageBase.DeviceVerificationaandActivation().deviceIMEITextbox); PageBase.DeviceVerificationaandActivation().deviceIMEITextbox.sendKeys(newIMEI2); PageBase.DeviceVerificationaandActivation().submitDVAButton.click(); driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI2)).click(); driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI2)) .sendKeys(simType2); PageBase.CommonControls().continueButtonDVA.click(); Thread.sleep(30000); Utilities.waitForElementVisible( driver.findElement(By.xpath(".//*[@id='retailPage']/section/form/span/div/button"))); String SupportCenterMessage = driver.findElement(By.xpath(".//*[@id='retailPage']/section/p")) .getText(); Reporter.log(" <br> <p> Support Center Message: " + SupportCenterMessage + " <br> <p>"); String toCompare = Constants.SUPPORT_PAGE_MESSAGE + "#" + ChildOrderId + " when calling."; Reporter.log(toCompare + " <br> <p>"); //Assert.assertTrue(SupportCenterMessage.contains(toCompare)); ShipAdminBaseClass.launchShipAdminInNewTab(); Reporter.log("Navigating to Parent Order: " + dependantValues.ORDER_ID + " <br> <p>"); PageBase.OrderSummaryPage().goToOrderSummaryPage(dependantValues.ORDER_ID); String eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(dependantValues.ORDER_ID); String parentOrderstatus = PageBase.OrderSummaryPage().getOrderStatus(); Assert.assertEquals(parentOrderstatus, Constants.SHIPPED); Assert.assertEquals(PageBase.OrderSummaryPage().getChildOrderId(), ChildOrderId); Assert.assertTrue(eventLogTableContent.contains(ChildOrderId)); PageBase.OrderSummaryPage().rOCHomeLink.click(); Reporter.log("Navigating to Child Order: " + ChildOrderId + " <br> <p>"); PageBase.OrderSummaryPage().goToOrderSummaryPage(ChildOrderId); eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(ChildOrderId); Assert.assertTrue(eventLogTableContent .contains("Old OrdId# " + dependantValues.ORDER_ID + ", Exchange order created")); String ChildOrderstatus = PageBase.OrderSummaryPage().getOrderStatus(); Assert.assertTrue(ChildOrderstatus.contains("In-Store Activation"), "Checking for In-store activation String failed"); Assert.assertEquals(PageBase.ReturnOrExchangeVerificationPage().parentOrderNumber.getText(), dependantValues.ORDER_ID, "Parent Order on Child Order is not the correct one. Check! <br> <p>"); eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(ChildOrderId); PageBase.InventoryManagementPage().launchInventoryInNewTab(); PageBase.InventoryManagementPage().verifyDeviceStatus(dependantValues.ESN_IMEI1, dependantValues.ESN_IMEI2, Constants.RETURN_TO_INVENTORY); } //DBError Verification DBError.navigateDBErrorPage(); Assert.assertTrue(PageBase.AdminPage().isDBErrorFound(initialCount)); }
From source file:com.consol.citrus.cucumber.step.runner.selenium.SeleniumStepsTest.java
License:Apache License
@Test public void testClick() { SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration(); when(seleniumBrowser.getName()).thenReturn("seleniumBrowser"); when(seleniumBrowser.getWebDriver()).thenReturn(webDriver); when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration); WebElement element = Mockito.mock(WebElement.class); when(element.isDisplayed()).thenReturn(true); when(element.isEnabled()).thenReturn(true); when(element.getTagName()).thenReturn("button"); when(webDriver.findElement(any(By.class))).thenAnswer(invocation -> { By select = (By) invocation.getArguments()[0]; Assert.assertEquals(select.getClass(), By.ById.class); Assert.assertEquals(select.toString(), "By.id: foo"); return element; });/*from w ww . j a v a2s. c om*/ steps.setBrowser("seleniumBrowser"); steps.click("id", "foo"); Assert.assertEquals(runner.getTestCase().getActionCount(), 1L); Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate() instanceof SeleniumAction); SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate(); Assert.assertEquals(action.getBrowser(), seleniumBrowser); Assert.assertTrue(action instanceof ClickAction); Assert.assertEquals(((ClickAction) action).getProperty(), "id"); Assert.assertEquals(((ClickAction) action).getPropertyValue(), "foo"); verify(element).click(); }
From source file:com.consol.citrus.cucumber.step.runner.selenium.SeleniumStepsTest.java
License:Apache License
@Test public void testSetInput() { SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration(); when(seleniumBrowser.getName()).thenReturn("seleniumBrowser"); when(seleniumBrowser.getWebDriver()).thenReturn(webDriver); when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration); WebElement element = Mockito.mock(WebElement.class); when(element.isDisplayed()).thenReturn(true); when(element.isEnabled()).thenReturn(true); when(element.getTagName()).thenReturn("input"); when(webDriver.findElement(any(By.class))).thenReturn(element); steps.setBrowser("seleniumBrowser"); steps.setInput("Hello", "id", "foo"); Assert.assertEquals(runner.getTestCase().getActionCount(), 1L); Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate() instanceof SeleniumAction); SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate();//from www .j a va2 s. c o m Assert.assertEquals(action.getBrowser(), seleniumBrowser); Assert.assertTrue(action instanceof SetInputAction); Assert.assertEquals(((SetInputAction) action).getValue(), "Hello"); Assert.assertEquals(((SetInputAction) action).getProperty(), "id"); Assert.assertEquals(((SetInputAction) action).getPropertyValue(), "foo"); verify(element).clear(); verify(element).sendKeys("Hello"); }
From source file:com.consol.citrus.cucumber.step.runner.selenium.SeleniumStepsTest.java
License:Apache License
@Test public void testCheckInput() { SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration(); when(seleniumBrowser.getName()).thenReturn("seleniumBrowser"); when(seleniumBrowser.getWebDriver()).thenReturn(webDriver); when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration); WebElement element = Mockito.mock(WebElement.class); when(element.isDisplayed()).thenReturn(true); when(element.isEnabled()).thenReturn(true); when(element.getTagName()).thenReturn("input"); when(webDriver.findElement(any(By.class))).thenReturn(element); steps.setBrowser("seleniumBrowser"); steps.checkInput("check", "id", "foo"); Assert.assertEquals(runner.getTestCase().getActionCount(), 1L); Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate() instanceof SeleniumAction); SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate();//from w ww .jav a 2 s. c om Assert.assertEquals(action.getBrowser(), seleniumBrowser); Assert.assertTrue(action instanceof CheckInputAction); Assert.assertEquals(((CheckInputAction) action).isChecked(), true); Assert.assertEquals(((CheckInputAction) action).getProperty(), "id"); Assert.assertEquals(((CheckInputAction) action).getPropertyValue(), "foo"); verify(element).click(); }
From source file:com.consol.citrus.cucumber.step.runner.selenium.SeleniumStepsTest.java
License:Apache License
@Test public void testShouldDisplay() { SeleniumBrowserConfiguration endpointConfiguration = new SeleniumBrowserConfiguration(); when(seleniumBrowser.getName()).thenReturn("seleniumBrowser"); when(seleniumBrowser.getWebDriver()).thenReturn(webDriver); when(seleniumBrowser.getEndpointConfiguration()).thenReturn(endpointConfiguration); WebElement element = Mockito.mock(WebElement.class); when(element.isDisplayed()).thenReturn(true); when(element.isEnabled()).thenReturn(true); when(element.getTagName()).thenReturn("button"); when(webDriver.findElement(any(By.class))).thenAnswer(invocation -> { By select = (By) invocation.getArguments()[0]; Assert.assertEquals(select.getClass(), By.ByName.class); Assert.assertEquals(select.toString(), "By.name: foo"); return element; });//from www.ja v a2 s . c o m steps.setBrowser("seleniumBrowser"); steps.should_display("name", "foo"); Assert.assertEquals(runner.getTestCase().getActionCount(), 1L); Assert.assertTrue(((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate() instanceof SeleniumAction); SeleniumAction action = (SeleniumAction) ((DelegatingTestAction) runner.getTestCase().getTestAction(0)) .getDelegate(); Assert.assertEquals(action.getBrowser(), seleniumBrowser); Assert.assertTrue(action instanceof FindElementAction); Assert.assertEquals(((FindElementAction) action).getProperty(), "name"); Assert.assertEquals(((FindElementAction) action).getPropertyValue(), "foo"); }
From source file:com.consol.citrus.selenium.actions.FindElementAction.java
License:Apache License
/** * Validates found web element with expected content. * @param element//from www.j a v a2s. c om * @param browser * @param context */ protected void validate(WebElement element, SeleniumBrowser browser, TestContext context) { validateElementProperty("tag-name", tagName, element.getTagName(), context); validateElementProperty("text", text, element.getText(), context); Assert.isTrue(displayed == element.isDisplayed(), String.format( "Selenium web element validation failed, " + "property 'displayed' expected '%s', but was '%s'", displayed, element.isDisplayed())); Assert.isTrue(enabled == element.isEnabled(), String.format( "Selenium web element validation failed, " + "property 'enabled' expected '%s', but was '%s'", enabled, element.isEnabled())); for (Map.Entry<String, String> attributeEntry : attributes.entrySet()) { validateElementProperty(String.format("attribute '%s'", attributeEntry.getKey()), attributeEntry.getValue(), element.getAttribute(attributeEntry.getKey()), context); } for (Map.Entry<String, String> styleEntry : styles.entrySet()) { validateElementProperty(String.format("css style '%s'", styleEntry.getKey()), styleEntry.getValue(), element.getCssValue(styleEntry.getKey()), context); } }
From source file:com.dhenton9000.selenium.d3.D3Tests.java
@Test /**//from w ww. ja v a 2 s . co m * note that this does not actually click on the point but needs to compute * the whole graph transform */ public void testContextMenu() { this.getAppspotRepository().initialNavigation(); gotoD3Page(); String cssSelector = "svg g[data-id=\"4\"]"; int x = 0, y = 0; //check that custom menu is not visible WebElement customMenu = getAutomation().findElement(SELECTOR_CHOICE.id, "my_custom_menu"); assertFalse(customMenu.isDisplayed()); ElementDimension dim = this.getAutomation().getJsMethods().getElementDimensions(cssSelector); this.getAutomation().getJsMethods().contextMenu(cssSelector, x + dim.left, y + dim.top); customMenu = getAutomation().findElement(SELECTOR_CHOICE.id, "my_custom_menu"); assertTrue(customMenu.isDisplayed()); }
From source file:com.digi.selenium.util.common.PageNavigation.java
protected void clickOnRadioRM25Broadband() { try {//from ww w .j av a2s .c o m WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[5]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }
From source file:com.digi.selenium.util.PageNavigation.java
protected void clickOnRadio30() { try {/* w w w .j av a2s. c o m*/ WebElement emailtxt = getDriver().findElement(By.id("reloadForm__email")); if (emailtxt.isDisplayed()) { handleInputField_ByID("reloadForm__email", AppConstants.EMAIL); Thread.sleep(500); } JavascriptExecutor js1 = (JavascriptExecutor) getDriver(); js1.executeScript("window.scrollBy(0,400)", ""); WebElement radio = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/ul/li[3]/label/div")); radio.click(); // now select check box to accept license agreement WebElement checkbox = getDriver().findElement(By.xpath("//*[@id='prepaidReloadForm']/label/div")); checkbox.click(); // click on proceed button after selecting radio button and check box // WebElement elementproceed=getDriver().findElement(By.xpath("//*[@id='proceedBtn']")); //*[@id="proceedBtn"] WebElement proceed = (new WebDriverWait(driver, 1000)) .until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='proceedBtn']"))); proceed.click(); waitForPageLoad(100); Thread.sleep(500); JavascriptExecutor js = (JavascriptExecutor) getDriver(); js.executeScript("window.scrollBy(0,500)", ""); } catch (Exception e) { System.out.println(e); e.printStackTrace(); log.error("Fail : Failed to Reload amount."); System.exit(0); } }