List of usage examples for org.openqa.selenium Keys CONTROL
Keys CONTROL
To view the source code for org.openqa.selenium Keys CONTROL.
Click Source Link
From source file:Config.m1SignupCreatemerchant.java
public void merchantwebsitevalidation(org.openqa.selenium.WebDriver driver) { GenerateData gendata = new GenerateData(); driver.findElement(By.id("merchant_website")).sendKeys(Keys.chord(Keys.CONTROL, "a"), gendata.generateUrl(20));/* w w w . j a va2 s . c o m*/ }
From source file:Config.m1SignupCreatemerchant.java
public void merchantfirstlastnamevalidation(org.openqa.selenium.WebDriver driver) throws InterruptedException { GenerateData genData = new GenerateData(); String desc;//from w w w. ja v a2 s. c o m String lastname = "MONETST" + genData.generateRandomString(10); driver.findElement(By.id("merchant_contact_person_attributes_first_name")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), lastname); Thread.sleep(1000); driver.findElement(By.id("merchant_contact_person_attributes_phone_number")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomNumber(8)); driver.findElement(By.id("merchant_contact_person_attributes_last_name")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomString(5)); sleep(1000); Thread.sleep(1000); //((JavascriptExecutor) driver).executeScript(" var checkboxes = document.getElementsByName('merchant[contact_email_matches_account_email]');for(var i=0, n=checkboxes.length;i<n;i++) { checkboxes[i].checked = true }"); String document = "Same Contact e-Mail as Login"; sleep(1000); new WebDriverWait(driver, 50) .until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//label[contains(., \"" + document + "\")]"))) .click(); driver.findElement(By.id("merchant_contact_email")).sendKeys(Keys.chord(Keys.CONTROL, "a"), merchantEmail); driver.findElement(By.id("merchant_contact_email_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"), merchantEmail); driver.findElement(By.id("merchant_company_house_number")).sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomNumber(4)); driver.findElement(By.id("merchant_company_street")).sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomString(10)); driver.findElement(By.id("merchant_company_house_number")).sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomNumber(4)); driver.findElement(By.id("merchant_company_postal_code")).sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomNumber(6)); }
From source file:Config.m1SignupCreatemerchant.java
public void merchantsveamount(WebDriver driver) throws InterruptedException { String sve = "2000"; GenerateData genData = new GenerateData(); //Map<Integer, Demo > testresultdata = new HashMap<Integer,Demo>(); driver.findElement(By.id("merchant_sve_amount")).sendKeys(Keys.chord(Keys.CONTROL, "a"), sve); sleep(1000);/*w w w .j a v a 2s. c o m*/ driver.findElement(By.linkText("Next")).click(); sleep(1000); driver.findElement(By.linkText("Next")).click(); String documentBusinessOwner1 = "I hereby confirm that I understand that my sales volume is above the established settlement cap and payment of some of the processed funds may be delayed."; new WebDriverWait(driver, 30).until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//label[contains(., \"" + documentBusinessOwner1 + "\")]"))) .click(); // new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(cssSelector("<tag name>[id*='Same as Contact Details']"))).click(); driver.findElement(By.linkText("Next")).click(); sleep(1000); if (driver.findElement(By.cssSelector("div[class = 'input string optional merchant_company_name']")) .isDisplayed()) { companynameRegistrationValidation(driver); sleep(1000); } if (driver.findElement(By.cssSelector("div[class = 'input string optional merchant_registration_number']")) .isDisplayed()) { WebElement element = driver.findElement(By.id("merchant_representative_person_matches_contact")); JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", element); sleep(1000); driver.findElement(By.linkText("Next")).click(); } sleep(2000); System.out.println("merchant_business_person_attributes_prefix"); if (driver.findElement(By.id("merchant_business_person_attributes_prefix")).isDisplayed()) { Select selectMerchantPrefix = new Select( driver.findElement(By.id("merchant_business_person_attributes_prefix"))); int iMerchantPrefix = selectMerchantPrefix.getOptions().size(); sleep(2000); Assert.assertEquals(4, iMerchantPrefix); sleep(2000); sleep(2000); selectMerchantPrefix.selectByValue("Mr"); Assert.assertEquals("Mr", selectMerchantPrefix.getFirstSelectedOption().getText()); sleep(2000); selectMerchantPrefix.selectByValue("Ms"); Assert.assertEquals("Ms", selectMerchantPrefix.getFirstSelectedOption().getText()); sleep(2000); selectMerchantPrefix.selectByValue("Mrs"); Assert.assertEquals("Mrs", selectMerchantPrefix.getFirstSelectedOption().getText()); System.out.println("merchant_business_person_attributes_prefix test completed"); //End : Merchant Attribute check //Start : Merchant Gender check Select selectMerchantGender = new Select( driver.findElement(By.id("merchant_business_person_attributes_gender"))); System.out.println("merchant_business_person_attributes_gender test started"); int iMerchantGender = selectMerchantGender.getOptions().size(); sleep(2000); Assert.assertEquals(3, iMerchantGender); sleep(2000); System.out.println("merchant_business_person_attributes_gender test started"); selectMerchantGender.selectByValue(""); Assert.assertEquals("Please Select", selectMerchantGender.getFirstSelectedOption().getText()); sleep(2000); selectMerchantGender.selectByValue("Male"); Assert.assertEquals("Male", selectMerchantGender.getFirstSelectedOption().getText()); sleep(2000); selectMerchantGender.selectByValue("Female"); Assert.assertEquals("Female", selectMerchantGender.getFirstSelectedOption().getText()); sleep(2000); driver.findElement(By.id("merchant_business_person_attributes_first_name")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomString(10)); driver.findElement(By.id("merchant_business_person_attributes_last_name")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomString(10)); Thread.sleep(1000); driver.findElement(By.linkText("Next")).click(); Thread.sleep(1000); driver.findElement(By.id("merchant_business_person_attributes_phone_number")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomNumber(8)); String nrictestdata = "S9515508A"; //nrictestdata = Utility.PickNRICdata(); System.out.println("nric value is " + nrictestdata); driver.findElement(By.id("merchant_business_person_attributes_nric")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), nrictestdata); sleep(5000); driver.findElement(By.linkText("Next")).click(); sleep(1000); while (driver.findElement(By.cssSelector( "div[class = 'input string required merchant_business_person_nric'] span[class='error']")) .isDisplayed()) { driver.findElement(By.id("merchant_business_person_attributes_nric")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), nrictestdata); sleep(5000); driver.findElement(By.linkText("Next")).click(); sleep(1000); } } driver.findElement(By.id("merchant_bank_account_holder_name")).sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateStringWithspace(10, " ")); Thread.sleep(2000); accountnumberValidation(driver); merchantbankbranchcode(driver); while (driver .findElement(By.cssSelector( "div[class = 'input string optional merchant_bank_branch_code'] span[class='error']")) .isDisplayed()) { merchantbankbranchcode(driver); } WebElement drpDwnList = driver.findElement(By.id("merchant_bank_code")); Select objSel = new Select(drpDwnList); List<WebElement> weblist = objSel.getOptions(); //Taking the count of items int iCnt = weblist.size(); //Using Random class to generate random values Random num = new Random(); int iSelect = num.nextInt(iCnt); //Selecting value from DropDownList objSel.selectByIndex(iSelect); //Selected Value System.out.println(drpDwnList.getAttribute("value")); driver.findElement(By.linkText("Next")).click(); Thread.sleep(1000); Thread.sleep(1000); WebElement element = driver.findElement(By.id("merchant_accepts_terms")); JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", element); driver.findElement(By.id("recaptcha_response_field")).sendKeys("99M1"); driver.findElement(By.xpath("//input[@value='Submit Application' and @type='submit']")).click(); }
From source file:Config.m1SignupCreatemerchant.java
public void merchantbankbranchcode(org.openqa.selenium.WebDriver driver) throws InterruptedException { Random BCValue = new Random(); Integer d = BCValue.nextInt(999); System.out.println("random number :" + d); String randomnumberstr = Integer.toString(d); System.out.println("random number :" + randomnumberstr); driver.findElement(By.id("merchant_bank_branch_code")).sendKeys(Keys.chord(Keys.CONTROL, "a"), randomnumberstr);//from ww w . j ava2 s .co m //driver.findElement(By.id("merchant_bank_account_number")).sendKeys("11117490"); Thread.sleep(1000); //sleep(1000) driver.findElement(By.id("merchant_bank_branch_code_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"), randomnumberstr); Thread.sleep(1000); }
From source file:Config.m1SignupCreatemerchant.java
public void accountnumberValidation(org.openqa.selenium.WebDriver driver) { Random AC = new Random(); Integer ACI = AC.nextInt(99999999); System.out.println("random number :" + ACI); String ACStr = Integer.toString(ACI); driver.findElement(By.id("merchant_bank_account_number")).sendKeys(Keys.chord(Keys.CONTROL, "a"), ACStr); driver.findElement(By.id("merchant_bank_account_number_confirmation")) .sendKeys(Keys.chord(Keys.CONTROL, "a"), ACStr); }
From source file:Config.m1SignupCreatemerchant.java
public void companynameRegistrationValidation(org.openqa.selenium.WebDriver driver) { GenerateData genData = new GenerateData(); if (driver.findElement(By.cssSelector("div[class = 'input string optional merchant_registration_number']")) .isDisplayed())//from ww w . ja v a2 s .c o m { String companyname = "company name" + genData.generateRandomString(5); driver.findElement(By.id("merchant_company_name")).sendKeys(Keys.chord(Keys.CONTROL, "a"), companyname); driver.findElement(By.id("merchant_registration_number")).sendKeys(Keys.chord(Keys.CONTROL, "a"), genData.generateRandomNumber(6)); } }
From source file:crawl.CrawlThread.java
License:Open Source License
@Override public void run() { WebDriver driver = new FirefoxDriver(); // The Firefox driver supports javascript Autenticate.perform(driver, fb_email, fb_password); try {/*from w w w . java 2 s. c o m*/ Thread.sleep(Globals.TIME_TO_LOGIN_IN_FB_MS); } catch (Exception ex) { System.out.println("InterruptedException in crawl.run()"); ex.printStackTrace(); System.exit(-1); } for (String post_id : post_list) { //OPEN NEW TAB WebElement body = driver.findElement(By.tagName("body")); body.sendKeys(Keys.CONTROL + "t"); Tree post = new Tree(post_id, GLOBALS); boolean result = post.crawl(driver); if (result) { post.prune(); post.print(); post.printEdgeList(); } else { body.sendKeys(Keys.CONTROL + "w"); } //SWITCH TAB ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tabs.get(tabs.size() - 1)); } driver.quit(); }
From source file:dagaz.controllers.SingleThread.java
private void renewWindows() throws Exception { resetRenewTimeStamp();/*from w w w.j a va2 s . c om*/ config.getRoot().appendDetails("--- Renewing.........."); if (driver != null) { driver.quit(); driver = null; Thread.sleep(5000); } driver = new RunningDriver().firefoxDriver(); driver.get(config.getTargetURL()); driver.manage().window().maximize(); login(); ArrayList<String> matchedArenas = new ArrayList<String>(); if (config.getArenas().size() < 1) { throw new Exception("No chosen arenas. Please add some...."); } for (String arena : config.getArenas()) { if (availableArenas.contains(arena)) { matchedArenas.add(arena); } else { config.getRoot().appendDetails("Arena [" + arena + "] is not available at the moment."); } } if (matchedArenas.size() < 1) { config.getRoot().appendDetails("Available Arenas: " + availableArenas); config.getRoot().appendDetails("Demand Arenas: " + config.getArenas()); throw new Exception("No matched Arena. Please check the selected Arenas!"); } while (driver.getWindowHandles().size() < matchedArenas.size()) { driver.findElement(By.tagName("body")).sendKeys(Keys.chord(Keys.CONTROL, "n")); } childControllers = new ArrayList<ChildController>(); for (String arena : matchedArenas) { childControllers.add(new ChildController(driver, arena, config)); } for (String windowName : driver.getWindowHandles()) { for (ChildController childController : childControllers) { if (childController.getWindowName() == null) { childController.setWindowName(windowName); break; } } } config.setIsNeedRenew(false); }
From source file:demo.seleniumtest.DemoTest.java
@Test public void test2() { //Write 2002 in the filter text and verify that we only see two rows final int expectedTableSizeTwo = 2; final int expectedTableSizeFive = 5; new WebDriverWait(driver, waitTime).until(new Function<WebDriver, Object>() { public Boolean apply(WebDriver wd) { wd.findElement(By.id("filter")); return true; }// w w w . j av a2 s . c o m }); driver.findElement(By.id("filter")).sendKeys("2002"); int actualTableSizeTwo = driver.findElement(By.id("tbodycars")).findElements(By.tagName("tr")).size(); driver.findElement(By.id("filter")).sendKeys(Keys.CONTROL + "a"); driver.findElement(By.id("filter")).sendKeys(Keys.DELETE); int actualTableSizeFive = driver.findElement(By.id("tbodycars")).findElements(By.tagName("tr")).size(); assertThat(actualTableSizeTwo, is(expectedTableSizeTwo)); assertThat(actualTableSizeFive, is(expectedTableSizeFive)); }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
/** * This allow to select multiple web elements matching the given path. * * @param path: to list of elements// w w w . j a va 2 s . co m * @param expectedElementCount: number of expected elements */ protected void selectMultipleElementsByPath(final By path, final int expectedElementCount) { List<WebElement> els = getElements(path, expectedElementCount); Actions multiSelect = new Actions(driver).keyDown(Keys.CONTROL); for (WebElement el : els) { multiSelect = multiSelect.click(el); } multiSelect.keyUp(Keys.CONTROL).build().perform(); }