예제 #1
0
  public void pesquisaPedido(WebDriver driver) throws InterruptedException {
    this.driver = driver;
    driver.get("http://*****:*****@id='btnPesquisar']/span[2]"));
    btnPesquisa.click();
  }
예제 #2
0
  @Test
  public void tagRSS_ie() throws InterruptedException {
    driver.get(
        "https://"
            + Constants.Alertname
            + ":"
            + Constants.Alertpass
            + "@www-qa.petfinder.com/user/login/");
    Thread.sleep(3000);
    Login page = new Login(driver);
    page.logIn();
    Thread.sleep(3000);
    driver.get(sURL);
    String URL = driver.getCurrentUrl();
    try {
      Assert.assertEquals(URL, sURL);
    } catch (Throwable t) {
      driver.get(sURL);
    }

    Thread.sleep(1320000);
    String newURL = driver.getCurrentUrl();
    try {
      Assert.assertEquals(newURL, eURL);
      System.out.println("Right page for...");
      System.out.println(sURL);
      System.out.println("Page redirected to " + newURL);
      System.out.println("");
    } catch (Throwable t) {
      System.out.println("Wrong page for...");
      System.out.println(sURL);
      System.out.println("Page redirected to " + newURL);
      System.out.println("");
    }
  }
 @Test
 public void testReserveringBevestigen() throws Exception {
   driver.get(baseUrl + "/Themaopdracht/loginpage.jsp");
   driver.findElement(By.name("username")).clear();
   driver.findElement(By.name("username")).sendKeys("Henk");
   driver.findElement(By.name("password")).clear();
   driver.findElement(By.name("password")).sendKeys("hww");
   driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
   driver.get("http://*****:*****@name='knop'])[2]")).click();
   driver.findElement(By.cssSelector("#content > form > p > input[name=\"knop\"]")).click();
   assertEquals(
       "De reservering is succesvol bevestigd",
       driver.findElement(By.cssSelector("h3.msg > span")).getText());
   driver.findElement(By.xpath("(//input[@name='knop'])[2]")).click();
   assertTrue(isElementPresent(By.cssSelector("h3.error")));
   driver.findElement(By.name("zoekviaID")).clear();
   driver.findElement(By.name("zoekviaID")).sendKeys("abc");
   driver.findElement(By.xpath("(//input[@name='knop'])[2]")).click();
   assertTrue(isElementPresent(By.cssSelector("h3.error")));
   driver.findElement(By.name("zoekviaID")).clear();
   driver.findElement(By.name("zoekviaID")).sendKeys("1");
   driver.findElement(By.xpath("(//input[@name='knop'])[2]")).click();
   assertTrue(isElementPresent(By.cssSelector("h3.error")));
 }
예제 #4
0
 @Test
 public void testUntitled() throws Exception {
   driver.get(baseUrl + "en/login");
   driver.findElement(By.id("signin_username")).clear();
   driver.findElement(By.id("signin_username")).sendKeys("admin");
   driver.findElement(By.id("signin_password")).clear();
   driver.findElement(By.id("signin_password")).sendKeys("admin");
   driver.findElement(By.cssSelector("button.button")).click();
   driver.get(baseUrl + "/en/profile/edit");
   driver.findElement(By.xpath("(//img[@alt='Leave this community'])[3]")).click();
   assertTrue(closeAlertAndGetItsText().matches("^Are you sure[\\s\\S]$"));
   driver.findElement(By.xpath("(//img[@alt='Leave this community'])[2]")).click();
   assertTrue(closeAlertAndGetItsText().matches("^Are you sure[\\s\\S]$"));
   driver.findElement(By.cssSelector("a[alt=\"Leave\"]")).click();
   assertTrue(closeAlertAndGetItsText().matches("^Are you sure[\\s\\S]$"));
   driver.findElement(By.id("profile_community_comunity")).click();
   new Select(driver.findElement(By.id("profile_community_community")))
       .selectByVisibleText("My Sample Community #1");
   driver.findElement(By.cssSelector("button")).click();
   new Select(driver.findElement(By.id("profile_community_community")))
       .selectByVisibleText("My Sample Community #2");
   driver.findElement(By.cssSelector("button")).click();
   new Select(driver.findElement(By.id("profile_community_community")))
       .selectByVisibleText("CAPS");
   driver.findElement(By.cssSelector("button")).click();
   driver.findElement(By.cssSelector("button.button.submitButton")).click();
 }
 public static void openWebsite(WebDriver driver) {
   if (localServer) {
     location = "http://localhost:8000/";
     driver.get(location);
   } else {
     location = "http://virtualfittingroom.herokuapp.com/";
     driver.get(location);
   }
 }
 @Test
 public void testVideoCaptureDriver() throws Exception {
   assertFalse(output.exists());
   WebDriver driver = new VideoCaptureDriver(new FirefoxDriver(), output);
   assertNotNull(driver);
   driver.get("http://www.google.com");
   driver.get("http://www.yahoo.com");
   driver.quit();
   assertTrue(output.exists());
 }
예제 #7
0
 @Before
 @After
 public void logout_and_clear_cookies() {
   try {
     webDriver.get(baseUrl + "/logout.do");
   } catch (org.openqa.selenium.TimeoutException x) {
     // try again - this should not be happening - 20 second timeouts
     webDriver.get(baseUrl + "/logout.do");
   }
   webDriver.manage().deleteAllCookies();
 }
예제 #8
0
  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    func = new COTFunctions(driver);
    driver.manage().timeouts().implicitlyWait(func.timeoutOFAllElement, TimeUnit.SECONDS);

    driver.get(func.baseUrl + "/");
    func.CheckLogin();
    func.LoginRole("SchoolAdmin");
    driver.get(func.baseUrl + "/college-search");
  }
예제 #9
0
  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    func = new COTFunctions(driver);
    wait = new WebDriverWait(driver, func.timeoutOfOneElement);
    driver.manage().timeouts().implicitlyWait(func.timeoutOFAllElement, TimeUnit.SECONDS);

    driver.get(func.baseUrl + "/");
    func.CheckLogin();
    func.LoginRole("Student");
    driver.get(func.baseUrl + "/document-locker");
  }
  public ObjectRepository(WebDriver driver) {
    driver = this.driver;
    if (driver.equals("chrome")) {
      System.setProperty("webdriver.chrome.driver", "C:/Seleniun/chromedriver.exe");
      driver = new ChromeDriver();
      driver.get("http://www.cleartrip.com");

    } else if (driver.equals("Firefox")) {
      driver = new FirefoxDriver();
      driver.get("http://www.cleartrip.com");
    }
  }
  public static LoginPage getPage(WebDriver driver, AutomationContext appMServer, LoginTo loginTo)
      throws IOException, XPathExpressionException {
    if (loginTo == LoginTo.PUBLISHER) {
      driver.get(appMServer.getContextUrls().getWebAppURLHttps() + PUBLISHER_LOGIN_URI);
    } else {
      driver.get(appMServer.getContextUrls().getWebAppURLHttps() + STORE_LOGIN_URI);
    }

    if (page == null || page.driver != driver) {
      page = new LoginPage(driver, appMServer);
    }
    return page;
  }
예제 #12
0
 @Test
 @Parameters("url")
 public void DoorTypepage(String url) throws InterruptedException, IOException {
   navigateDoorTypePage(driver);
   manualSignup(driver, "test_user", "DoorTypePage");
   manualSignin(driver, "test_user", "DoorTypePage", url);
   driver.get(url);
   navigateDoorTypePage(driver);
   signinFB(driver, "DoorTypePage", url);
   driver.get(url);
   navigateDoorTypePage(driver);
   signinGoogle(driver, "DoorTypePage", url);
   driver.get(url);
 }
예제 #13
0
 @Test
 public void canStartMultipleIeDriverInstances() {
   WebDriver firstDriver = newIeDriver();
   WebDriver secondDriver = newIeDriver();
   try {
     firstDriver.get(pages.xhtmlTestPage);
     secondDriver.get(pages.formPage);
     assertEquals("XHTML Test Page", firstDriver.getTitle());
     assertEquals("We Leave From Here", secondDriver.getTitle());
   } finally {
     firstDriver.quit();
     secondDriver.quit();
   }
 }
예제 #14
0
  @Before
  @After
  public void logout_and_clear_cookies() {
    restTemplate = serverRunning.getRestTemplate();

    try {
      webDriver.get(baseUrl + "/logout.do");
    } catch (org.openqa.selenium.TimeoutException x) {
      // try again - this should not be happening - 20 second timeouts
      webDriver.get(baseUrl + "/logout.do");
    }
    webDriver.get(appUrl + "/j_spring_security_logout");
    webDriver.manage().deleteAllCookies();
  }
예제 #15
0
  @Test
  public void shouldNotifyUserWhenEmailAddressesAreDifferent() {
    driver.get(URL);
    String title = driver.getTitle();
    assertEquals("Rule Financial Registration Form", title);

    int randomIntNUmberForRegistration = this.generator.nextInt(100000);

    driver.findElement(By.name("firstName")).clear();
    driver.findElement(By.name("firstName")).sendKeys("Marcin");
    driver.findElement(By.name("lastName")).clear();
    driver.findElement(By.name("lastName")).sendKeys("Kowalczyk");

    String email = new String("marcinkowalczyk" + randomIntNUmberForRegistration + "@gmail.com");

    driver.findElement(By.name("email")).clear();
    driver.findElement(By.name("email")).sendKeys(email);
    driver.findElement(By.name("repeatEmail")).clear();
    driver.findElement(By.name("repeatEmail")).sendKeys("wrong" + email);

    WebElement divErrorEmailAdress =
        driver.findElement(By.xpath("html/body/div[2]/div[2]/div/div/div/div[5]/div/div"));
    boolean ariaHidden = Boolean.getBoolean(divErrorEmailAdress.getAttribute("aria-hidden"));
    assertEquals(ariaHidden, false);
  }
예제 #16
0
  @Test
  public void shouldShowCorrectAnswerPopupWhenAnswerIsCorrect() {
    driver.get(URL);
    String title = driver.getTitle();
    assertEquals("Rule Financial Registration Form", title);

    this.fillRegistrationFields();
    driver.findElement(By.xpath("//*[@class='gwt-Button' and text()='Java']")).click();
    if (this.chooseTypeOfAnswerForQuestion(true)) {
      driver.findElement(By.xpath("//*[@id='gwt-uid-26']")).click(); // checkBox on the site
      // Save button             | //*[text()='Save']
      driver
          .findElement(By.xpath("html/body/div[2]/div[2]/div/div/div/table/tbody/tr/td[1]/button"))
          .click();

      String alertText =
          driver
              .findElement(By.xpath("html/body/div[5]/div/div/table/tbody/tr[1]/td/div"))
              .getText();
      // close an alert
      driver.findElement(By.xpath("//button[text()='Close']")).click();
      assertEquals("Congratulations! You've won:", alertText);
    } else {
      System.out.println("Błąd z zaznaczeniem check box, lub przyciskiem Save");
    }
  }
예제 #17
0
  @Test
  public void shouldShowWrongAnswerPopupWhenAsnwerIsIncorrect() {
    driver.get(URL);
    String title = driver.getTitle();
    assertEquals("Rule Financial Registration Form", title);
    /*
     * Your code needs to be here, sample below should help you a bit
     * driver.findElement(By.name("firstName")).clear();
     * driver.findElement(By.name("firstName")).sendKeys("Marek");
     */
    this.fillRegistrationFields();
    driver.findElement(By.xpath("//*[@class='gwt-Button' and text()='Java']")).click();
    if (this.chooseTypeOfAnswerForQuestion(false)) {
      driver.findElement(By.xpath("//*[@id='gwt-uid-26']")).click(); // checkBox on the site
      // Save button             | //*[text()='Save']
      driver
          .findElement(By.xpath("html/body/div[2]/div[2]/div/div/div/table/tbody/tr/td[1]/button"))
          .click();

      String alertText =
          driver
              .findElement(By.xpath("html/body/div[5]/div/div/table/tbody/tr[1]/td/div"))
              .getText();
      // close an alert
      driver.findElement(By.xpath("//button[text()='Close']")).click();
      assertEquals("We're sorry but your answer was incorrect.", alertText);
    } else {
      System.out.println("Błąd z zaznaczeniem check box, lub przyciskiem Save");
    }
  }
 @Test
 public void basic() throws Exception {
   driver.get("http://www.amazon.com/");
   assertEquals(
       "Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more",
       driver.getTitle());
 }
 // mark the grid 100% busy = having 1 firefox test running.
 @Test
 public void test() throws MalformedURLException, InterruptedException {
   DesiredCapabilities ff = DesiredCapabilities.firefox();
   runningOne = new RemoteWebDriver(new URL(hubURL + "/grid/driver"), ff);
   runningOne.get(hubURL + "/grid/console");
   Assert.assertEquals(runningOne.getTitle(), "Grid overview");
 }
예제 #20
0
  @Test(expected = NoSuchElementException.class)
  public void shouldBeAbleToClickInAFrame() throws InterruptedException {
    WebDriver d = getDriver();

    d.get("http://docs.wpm.neustar.biz/testscript-api/index.html");
    assertEquals("__MAIN_FRAME__", getCurrentFrameName(d));

    d.switchTo().frame("classFrame");
    assertEquals("classFrame", getCurrentFrameName(d));

    // This should cause a reload in the frame "classFrame"
    d.findElement(By.linkText("HttpClient")).click();

    // Wait for new content to load in the frame.
    WebDriverWait wait = new WebDriverWait(d, 10);
    wait.until(ExpectedConditions.titleContains("HttpClient"));

    // Frame should still be "classFrame"
    assertEquals("classFrame", getCurrentFrameName(d));

    // Check if a link "clearCookies()" is there where expected
    assertEquals("clearCookies", d.findElement(By.linkText("clearCookies")).getText());

    // Make sure it was really frame "classFrame" which was replaced:
    // 1. move to the other frame "packageFrame"
    d.switchTo().defaultContent().switchTo().frame("packageFrame");
    assertEquals("packageFrame", getCurrentFrameName(d));
    // 2. the link "clearCookies()" shouldn't be there anymore
    d.findElement(By.linkText("clearCookies"));
  }
예제 #21
0
  public static void main(String[] args) {

    // Here we need to create logger instance so we need to pass Class name for
    // which  we want to create log file in my case Google is classname
    Logger logger = Logger.getLogger("Google");

    // configure log4j properties file
    PropertyConfigurator.configure("C:\\Users\\chinwahc\\selenium\\Logging\\Log4j.properties");

    // Open browser
    WebDriver driver = new FirefoxDriver();
    logger.info("Browser Opened");

    // Set implicit wait
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    logger.info("Implicit wait given");

    // Load application
    driver.get("https://www.google.co.in/");
    logger.info("Url opened");

    // type Selenium
    driver.findElement(By.name("q")).sendKeys("Selenium");
    logger.info("keyword type");
  }
  /**
   * 取得新闻标题、时间和评论数的集合
   *
   * @param urls 所有新闻URL集合
   * @return 新闻标题、时间和评论数的集合
   */
  public static List<String> getTimeAndJoin(List<String> urls) {
    List<String> listTimeAndJoin = new ArrayList<String>();

    int num = 1;
    // System.setProperty("webdriver.ie.driver", "." + File.separator + "Driver" + File.separator +
    // "IEDriverServer.exe");
    // WebDriver driver = new InternetExplorerDriver();
    WebDriver driver = new FirefoxDriver();
    for (int i = 0; i < urls.size(); i++) {
      // System.setProperty("webdriver.ie.driver", "." + File.separator + "Driver" + File.separator
      // + "IEDriverServer.exe");
      // WebDriver driver = new InternetExplorerDriver();
      driver.get(urls.get(i));
      List<WebElement> headline =
          driver.findElements(By.cssSelector("div[class='atitle tCenter']"));
      List<WebElement> timeAndJoin = driver.findElements(By.cssSelector("div[class='about']"));

      StringBuffer sb = null;
      sb = new StringBuffer();

      if ((timeAndJoin.size() == 1) && (headline.size() == 1)) {
        sb.append("[新闻 " + num + "]");
        sb.append(headline.get(0).getText() + "\t");
        String[] temp = timeAndJoin.get(0).getText().split("\n");
        sb.append(temp[0] + "\t" + temp[1] + "\t" + temp[2]);
        // sb.append(timeAndJoin.get(0).getText().replaceAll("\\s+", ""));
        listTimeAndJoin.add(sb.toString());
        num++;
      }
      // driver.close();
    }
    driver.close();
    return listTimeAndJoin;
  }
예제 #23
0
  public void testAwsppWebDriver(int docs, int times) throws InterruptedException {
    init();
    WebDriver driver = new FirefoxDriver();
    //		WebDriver driver = new HtmlUnitDriver();
    for (int j = 0; j < times; j++) {
      driver.get(baseUrl);
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      // create/resume transaction

      WebElement docs_input = driver.findElement(By.id("create_docs_1"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      docs_input.clear();
      docs_input.sendKeys("" + docs);

      WebElement createButton = driver.findElement(By.id("resume"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      createButton.click();
      for (int i = 0; i < docs; i++) {

        WebElement img = driver.findElement(By.xpath("//img[@alt='Click to sign']"));
        driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
        img.click();

        WebElement submitButton = driver.findElement(By.name("button"));
        driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);

        submitButton.click();
      }
      WebElement link = driver.findElement(By.linkText("Go Back to Parent Page"));
      driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
      link.click();
    }
    driver.close();
  }
 private void doSomething() {
   WebDriver driver = WebDriverFactory.getDriver(DesiredCapabilities.firefox());
   driver.get("http://seleniumhq.org/");
   driver.findElement(By.name("q")).sendKeys("selenium");
   driver.findElement(By.id("submit")).click();
   new WebDriverWait(driver, 30).until(ExpectedConditions.titleContains("Google Custom Search"));
 }
예제 #25
0
  @Parameters("browser")
  @BeforeClass

  // Passing Browser parameter from TestNG xml

  public void beforeTest(String browser) {

    // If the browser is Firefox, then do this

    if (browser.equalsIgnoreCase("firefox")) {

      driver = new FirefoxDriver();

      // If browser is IE, then do this

    } else if (browser.equalsIgnoreCase("ie")) {

      // Here I am setting up the path for my IEDriver

      System.setProperty("webdriver.ie.driver", "C:/driver/IEDriverServer.exe");

      driver = new InternetExplorerDriver();
    }

    // Doesn't the browser type, lauch the Website

    driver.get("http://www.facebook.com");
    driver.manage().window().maximize();
  }
예제 #26
0
 @BeforeTest
 public void setup() {
   this.driver = new FirefoxDriver();
   page = PageFactory.initElements(driver, pages.class);
   driver.get(page.url);
   driver.manage().window().maximize();
 }
예제 #27
0
 public static void main(String... args) {
   WebDriver driver = new FirefoxDriver();
   driver.get("file:///home/daz/Downloads/WebDriver/8850OS_Code/Chapter%202/HTML/DragMe.html");
   WebElement dragMe = driver.findElement(By.id("draggable"));
   Actions builder = new Actions(driver);
   builder.dragAndDropBy(dragMe, 300, 200).perform();
 }
 @BeforeTest
 void beforeTest() {
   initDriver();
   driver = getDriver();
   baseURL = testconfig.readNode("urlbase");
   driver.get(baseURL);
 }
예제 #29
0
파일: New4.java 프로젝트: TKosmacki/CS1632
 @Test
 public void testEditProfile() throws Exception {
   driver.get(baseUrl + "/");
   driver.findElement(By.xpath("(//a[contains(text(),'log in')])[2]")).click();
   driver.findElement(By.xpath("(//a[contains(text(),'log in')])[2]")).click();
   driver.findElement(By.id("email")).click();
   driver.findElement(By.id("email")).clear();
   driver.findElement(By.id("email")).sendKeys("*****@*****.**");
   driver.findElement(By.id("password")).clear();
   driver.findElement(By.id("password")).sendKeys("Eliandtyler1");
   driver.findElement(By.id("submit-button")).click();
   driver.findElement(By.id("submit-button")).click();
   driver.findElement(By.cssSelector("img.avatar-me.js-avatar-me")).click();
   driver.findElement(By.cssSelector("img.avatar-me.js-avatar-me")).click();
   driver.findElement(By.linkText("Edit Profile & Settings")).click();
   driver.findElement(By.linkText("Edit Profile & Settings")).click();
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
   // Warning: assertTextPresent may require manual changes
   assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*$"));
 }
예제 #30
0
 private void goToTestPage(WebDriver driver) {
   driver.get(baseUrl);
   driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
   // create/resume transaction
   WebElement createButton = driver.findElement(By.id("resume"));
   driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
 }