コード例 #1
0
  @Override
  public void mouseMoveAt(String locator, String coordString) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    if (coordString.contains(",")) {
      String[] coords = coordString.split(",");

      int x = GetterUtil.getInteger(coords[0]);
      int y = GetterUtil.getInteger(coords[1]);

      actions.moveToElement(webElement, x, y);
      actions.clickAndHold(webElement);
    } else {
      actions.moveToElement(webElement);
      actions.clickAndHold(webElement);
    }

    Action action = actions.build();

    action.perform();
  }
コード例 #2
0
  /**
   * @param model Lets say there is header menu bar, on hovering the mouse, drop down should be
   *     displayed
   */
  public void dropDownByMouseHover(MethodParameters model) {
    Actions action = new Actions(WebDriverClass.getInstance());

    action.moveToElement(model.getElement().get(0)).perform();
    WebElement subElement = WebDriverClass.getInstance().findElement(By.xpath(model.getData()));
    action.moveToElement(subElement);
    action.click().build().perform();
  }
コード例 #3
0
ファイル: MainPage.java プロジェクト: hemspraxis/viaticos
 public AgregarMovimientosPage linkToAgregarMovimientosEmpleado() {
   Actions action = new Actions(driver);
   waitForWebElementDisplayed(menuViaticos);
   action.moveToElement(menuViaticos).click().perform();
   waitForWebElementDisplayed(parentNodeEstadoCuentaEmpleado);
   action.moveToElement(parentNodeEstadoCuentaEmpleado).perform();
   waitForWebElementDisplayed(agregarMovimientoEmpleado);
   action.moveToElement(agregarMovimientoEmpleado).click().perform();
   return new AgregarMovimientosPage(driver).loadPage();
 }
コード例 #4
0
ファイル: MainPage.java プロジェクト: hemspraxis/viaticos
 public MisViajesPage linkToMisViajes() {
   Actions action = new Actions(driver);
   waitForWebElementDisplayed(menuViaticos);
   action.moveToElement(menuViaticos).click().perform();
   waitForWebElementDisplayed(parentNodeViajes);
   action.moveToElement(parentNodeViajes).perform();
   waitForWebElementDisplayed(misViajes);
   action.moveToElement(misViajes).click().perform();
   return new MisViajesPage(driver).loadPage();
 }
コード例 #5
0
ファイル: MainPage.java プロジェクト: hemspraxis/viaticos
 public CotizarViajePage linkToCotizarViaje() {
   Actions action = new Actions(driver);
   waitForWebElementDisplayed(menuViaticos);
   action.moveToElement(menuViaticos).click().perform();
   waitForWebElementDisplayed(parentNodeViajes);
   action.moveToElement(parentNodeViajes).perform();
   waitForWebElementDisplayed(cotizacion);
   action.moveToElement(cotizacion).click().perform();
   return new CotizarViajePage(driver).loadPage();
 }
コード例 #6
0
ファイル: MainPage.java プロジェクト: hemspraxis/viaticos
 public AutorizarComprobacionPage linkToAutorizarComprobacion() {
   Actions action = new Actions(driver);
   waitForWebElementDisplayed(menuViaticos);
   action.moveToElement(menuViaticos).click().perform();
   waitForWebElementDisplayed(parentNodeComprobaciones);
   action.moveToElement(parentNodeComprobaciones).perform();
   waitForWebElementDisplayed(autorizarComprobacion);
   action.moveToElement(autorizarComprobacion).click().perform();
   return new AutorizarComprobacionPage(driver).loadPage();
 }
コード例 #7
0
  public void openVid() throws InterruptedException {
    Actions action = new Actions(driver);

    WebElement wa = driver.findElement(searchButton);
    action.moveToElement(wa).build().perform();

    Thread.sleep(2000);

    WebElement waa = driver.findElement(searchVideoButton);
    action.moveToElement(waa).click().build().perform();
  }
コード例 #8
0
ファイル: Base.java プロジェクト: kashenaf/Selenium2015
 public void mouseHoverByXpath(String locator) {
   try {
     WebElement element = driver.findElement(By.xpath(locator));
     Actions action = new Actions(driver);
     Actions hover = action.moveToElement(element);
   } catch (Exception ex) {
     System.out.println("First attempt has been done, This is second try");
     WebElement element = driver.findElement(By.cssSelector(locator));
     Actions action = new Actions(driver);
     action.moveToElement(element).perform();
   }
 }
コード例 #9
0
ファイル: InputTextUITest.java プロジェクト: lokeshrj/aura
  @TargetBrowsers({BrowserType.GOOGLECHROME})
  public void doTestUpdateOnAttributeWithCertainEventsChrome(String url) throws Exception {
    open(url);
    String value = getCurrentModelValue();
    WebDriver d = getDriver();
    Actions a = new Actions(d);

    WebElement outputDiv = findDomElement(By.id("output"));

    String eventName = "dblclick";
    WebElement input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.doubleClick(input).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mousemove";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.moveToElement(input).moveByOffset(0, 100).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseout";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.moveToElement(input).moveToElement(outputDiv).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseover";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    outputDiv.click();
    a.moveToElement(input).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseup";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    input.click();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "select";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.doubleClick(input).build().perform();
    value = assertModelValue(eventName);
  }
コード例 #10
0
  public static void main(String[] args) throws InterruptedException {

    WebDriver driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    driver.get("http://facebook.com");

    driver.findElement(By.xpath("//input[@id='email']")).sendKeys("*****@*****.**");
    driver.findElement(By.xpath("//input[@id='pass']")).sendKeys("Temp@123");
    driver.findElement(By.xpath("//input[@id='pass']")).sendKeys(Keys.ENTER);

    driver.findElement(By.xpath("//div[@id='pagelet_welcome_box']/div/a")).click();
    driver.findElement(By.xpath("//div[@id='fbTimelineHeadline']/div[2]/div/a[4]")).click();

    List<WebElement> friends = driver.findElements(By.xpath("//div[@class='fsl fwb fcb']/a"));
    System.out.println("Total friends -> " + friends.size());
    int newFriends = friends.size(); // 20 40 60
    Actions act = new Actions(driver);

    int oldFriends = 0; // 0 20 40 60
    while (newFriends != oldFriends) {
      oldFriends = newFriends;
      WebElement lastFriend = friends.get(friends.size() - 1);
      act.moveToElement(lastFriend).build().perform(); // 20th
      Thread.sleep(3000);
      friends = driver.findElements(By.xpath("//div[@class='fsl fwb fcb']/a"));
      newFriends = friends.size();
      System.out.println("Total friends -> " + friends.size());
    }

    System.out.println("FINAL Total friends -> " + friends.size());
    for (int i = 0; i < friends.size(); i++) {
      System.out.println(friends.get(i).getText());
    }
  }
コード例 #11
0
 protected void appendText(WebElement inputElement, String text) {
   Actions actions = new Actions(driver);
   actions.moveToElement(inputElement);
   actions.click();
   actions.sendKeys(text);
   actions.perform();
 }
コード例 #12
0
  /**
   * Finds the menu that can be used by the owner to control the participant. Hovers over it. Finds
   * the mute link and mute it. Then checks in the second participant page whether it is muted
   */
  public void ownerMutesParticipantAndCheck() {
    System.err.println("Start ownerMutesParticipantAndCheck.");

    WebDriver owner = ConferenceFixture.getOwner();

    WebElement elem =
        owner.findElement(By.xpath("//div[@class='remotevideomenu']/i[@class='fa fa-angle-down']"));

    Actions action = new Actions(owner);
    action.moveToElement(elem);
    action.perform();

    TestUtils.waitForDisplayedElementByXPath(
        owner, "//ul[@class='popupmenu']/li/a[@class='mutelink']", 5);

    owner.findElement(By.xpath("//ul[@class='popupmenu']/li/a[@class='mutelink']")).click();

    // and now check whether second participant is muted
    TestUtils.waitForElementByXPath(
        ConferenceFixture.getSecondParticipant(),
        "//span[@class='audioMuted']/i[@class='icon-mic-disabled']",
        5);

    action.release();
  }
コード例 #13
0
  @Test
  public void testDataViewTreeMapPopUpData() {
    searchByLinkAndClick(CLUSTER_VIEW_LABEL);
    searchByLinkAndClick(DATA_DROPDOWN_ID);
    WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
    Actions builder = new Actions(driver);
    builder.clickAndHold(TreeMapMember).perform();
    String RegionType =
        driver
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
            .getText();
    String regionType = JMXProperties.getInstance().getProperty("region.R2.regionType");
    Assert.assertEquals(regionType, RegionType);

    String EntryCount =
        driver
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div"))
            .getText();
    String entryCount = JMXProperties.getInstance().getProperty("region.R2.systemRegionEntryCount");
    Assert.assertEquals(entryCount, EntryCount);

    String EntrySizetemp =
        driver
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div"))
            .getText();
    float EntrySize = Float.parseFloat(EntrySizetemp);
    float entrySize =
        Float.parseFloat(JMXProperties.getInstance().getProperty("region.R2.entrySize"));
    entrySize = entrySize / 1024 / 1024;
    entrySize = Float.parseFloat(new DecimalFormat("##.####").format(entrySize));
    Assert.assertEquals(entrySize, EntrySize);
    builder.moveToElement(TreeMapMember).release().perform();
  }
コード例 #14
0
  public void clickViewPhotoLink(int panelBodyIndex, String urlRegex) throws Exception {
    String idOfPanelBody = "panelBodyCollapse-" + panelBodyIndex;
    WebElement photoCell =
        browser
            .driver
            .findElement(By.id(idOfPanelBody))
            .findElements(By.cssSelector(".profile-pic-icon-click"))
            .get(0);
    JavascriptExecutor jsExecutor = (JavascriptExecutor) browser.driver;
    jsExecutor.executeScript(
        "document.getElementById('"
            + idOfPanelBody
            + "')"
            + ".getElementsByClassName('profile-pic-icon-click')[0]"
            + ".getElementsByTagName('a')[0].click();");
    Actions actions = new Actions(browser.driver);

    actions.moveToElement(photoCell).perform();
    waitForElementPresence(By.cssSelector(".popover-content > img"));

    List<WebElement> photos = browser.driver.findElements(By.cssSelector(".popover-content > img"));
    AssertHelper.assertContainsRegex(urlRegex, photos.get(photos.size() - 1).getAttribute("src"));

    actions.moveByOffset(100, 100).click().perform();
  }
コード例 #15
0
  public void hoverClickAndViewStudentPhotoOnHeading(int panelHeadingIndex, String urlRegex)
      throws Exception {
    JavascriptExecutor jsExecutor = (JavascriptExecutor) browser.driver;
    String idOfPanelHeading = "panelHeading-" + panelHeadingIndex;
    WebElement photoDiv =
        browser
            .driver
            .findElement(By.id(idOfPanelHeading))
            .findElement(By.className("profile-pic-icon-hover"));
    jsExecutor.executeScript("arguments[0].scrollIntoView(true);", photoDiv);
    Actions actions = new Actions(browser.driver);
    actions.moveToElement(photoDiv).perform();
    waitForElementPresence(By.cssSelector(".popover-content"));

    jsExecutor.executeScript(
        "document.getElementsByClassName('popover-content')[0]"
            + ".getElementsByTagName('a')[0].click();");

    waitForElementPresence(By.cssSelector(".popover-content > img"));

    AssertHelper.assertContainsRegex(
        urlRegex,
        browser
            .driver
            .findElements(By.cssSelector(".popover-content > img"))
            .get(0)
            .getAttribute("src"));

    jsExecutor.executeScript(
        "document.getElementsByClassName('popover')[0].parentNode.removeChild(document.getElementsByClassName('popover')[0])");
  }
コード例 #16
0
 /**
  * Mouse Over on the the given element.
  *
  * @return Parent instance
  */
 public ParentPanel mouseOver() {
   getWebElement().getSize(); // for scroll to object
   logAction(this, getParentClassName(), "mouseOver");
   Actions builder = new Actions(getDriver());
   builder.moveToElement(getWebElement()).build().perform();
   return parent;
 }
コード例 #17
0
  public void hoverAndViewStudentPhotoOnBody(int panelBodyIndex, String urlRegex) throws Exception {
    String idOfPanelBody = "panelBodyCollapse-" + panelBodyIndex;
    WebElement photoLink =
        browser
            .driver
            .findElements(By.cssSelector('#' + idOfPanelBody + "> .panel-body > .row"))
            .get(0)
            .findElements(By.className("profile-pic-icon-hover"))
            .get(0);
    Actions actions = new Actions(browser.driver);
    actions.moveToElement(photoLink).perform();

    waitForElementPresence(By.cssSelector(".popover-content > img"));
    ThreadHelper.waitFor(500);

    AssertHelper.assertContainsRegex(
        urlRegex,
        browser
            .driver
            .findElements(By.cssSelector(".popover-content > img"))
            .get(0)
            .getAttribute("src"));

    JavascriptExecutor jsExecutor = (JavascriptExecutor) browser.driver;
    jsExecutor.executeScript(
        "document.getElementsByClassName('popover')[0].parentNode.removeChild(document.getElementsByClassName('popover')[0])");
  }
コード例 #18
0
  @Override
  public void clickAt(String locator, String coordString) {
    if (locator.contains("x:")) {
      String url = getHtmlNodeHref(locator);

      open(url);
    } else {
      WebElement webElement = getWebElement(locator);

      if (coordString.contains(",")) {
        WrapsDriver wrapsDriver = (WrapsDriver) webElement;

        WebDriver webDriver = wrapsDriver.getWrappedDriver();

        Actions actions = new Actions(webDriver);

        String[] coords = coordString.split(",");

        int x = GetterUtil.getInteger(coords[0]);
        int y = GetterUtil.getInteger(coords[1]);

        actions.moveToElement(webElement, x, y);
        actions.click();

        Action action = actions.build();

        action.perform();
      } else {
        webElement.click();
      }
    }
  }
コード例 #19
0
ファイル: AuraUITestingUtil.java プロジェクト: synle/aura
 /**
  * use to do mouse over the element
  *
  * @param elem
  */
 public void setHoverOverElement(String elem) {
   Actions builder = new Actions(driver);
   // find the element a 2nd time which helps get around the IE hover issues by focusing the
   // element
   WebElement element = driver.findElement(By.className(elem));
   builder.moveToElement(element).build().perform();
 }
コード例 #20
0
ファイル: UGElement.java プロジェクト: uiguard/uiguard
 @Override
 public IUGElement mouseOver() {
   // Only support chrome by this time
   driver.extension().robotMouseMove(0, 0);
   builder.moveToElement(element).build().perform();
   return this;
 }
コード例 #21
0
ファイル: ArchiveSearchPageIT.java プロジェクト: piyush76/EMS
 protected void forcePageLoad() throws Exception {
   logMsg("Forcing page load by sending END key to folder list");
   WebElement e = getJspTestUtils().findElement(By.id("folderList"));
   Actions clicker = new Actions(getJspTestUtils().getDriver());
   clicker.moveToElement(e);
   clicker.sendKeys(e, Keys.END);
   clicker.perform();
 }
コード例 #22
0
 public static void hoverClick(WebDriver driver, String hover) throws InterruptedException {
   Thread.sleep(2000);
   Actions builder = new Actions(driver);
   Actions hoverOverRegistrar = builder.moveToElement(driver.findElement(By.xpath(hover)));
   hoverOverRegistrar.perform();
   driver.findElement(By.linkText("Sign Out")).click();
   Thread.sleep(1000);
 }
コード例 #23
0
  /**
   * Tests whether the row is higlighted when mouse is over it, the class of the row is changed, it
   * then contains active row string
   *
   * @param row
   * @return true if the row is highlighted, false otherwise
   */
  private boolean isRowHighlighted(WebElement row) {

    actions.moveToElement(row).perform();

    String rowClass = row.getAttribute("class");

    return rowClass.contains("active-row");
  }
コード例 #24
0
 public PressureDialog gotoPressureDialog() {
   WebElement pressureLink = webDriver.findElement(By.id("pressure-link"));
   Actions builder = new Actions(webDriver);
   System.out.println(pressureLink.getAttribute("href"));
   builder.moveToElement(pressureLink).perform();
   System.out.println(pressureLink.getAttribute("href"));
   pressureLink.click();
   return pageBinder.bind(PressureDialog.class);
 }
コード例 #25
0
ファイル: TestBase.java プロジェクト: ibmer921150/xero-test
 protected void clickSubmenu(By menu, By submenu) {
   Actions action = new Actions(driver);
   action
       .moveToElement(driver.findElement(menu))
       .moveToElement(driver.findElement(submenu))
       .click()
       .build()
       .perform();
 }
コード例 #26
0
 /**
  * Focus on the Element(WebElement)
  *
  * @return Parent instance
  */
 public ParentPanel focus() {
   Dimension size = getWebElement().getSize(); // for scroll to object
   logAction(this, getParentClassName(), "focus");
   Actions builder = new Actions(getDriver());
   org.openqa.selenium.interactions.Action focus =
       builder.moveToElement(getWebElement(), size.width / 2, size.height / 2).build();
   focus.perform();
   return parent;
 }
コード例 #27
0
ファイル: NewTest.java プロジェクト: Jdoing/Workspace
 @Test(dependsOnMethods = {"start"})
 public void locate() {
   dr.findElement(By.xpath("//button[contains(text(),'项目管理')]")).click();
   WebElement elt_lxsq = dr.findElement(By.linkText("立项申请"));
   Actions action = new Actions(dr);
   action.moveToElement(elt_lxsq);
   action.perform();
   dr.findElement(By.xpath("//*[contains(text(),'立项申请(30万以下切块投资项目)')]")).click();
 }
コード例 #28
0
ファイル: Element.java プロジェクト: yuliapetrova/JDITraining
 public void mouseOver() {
   invoker.doJAction(
       "Move mouse over Element",
       () -> {
         getWebElement().getSize(); // for scroll to object
         Actions builder = new Actions(getDriver());
         builder.moveToElement(getWebElement()).build().perform();
       });
 }
コード例 #29
0
 // Select EDIT
 public void selectEditPermission() {
   Actions action = new Actions(driver);
   action
       .moveToElement(permissionsMenu)
       .click()
       .moveToElement(shareWithEdit)
       .click()
       .build()
       .perform();
 }
コード例 #30
0
ファイル: BasePage.java プロジェクト: prakumar/CMP-Automation
 public void focusElement(String locator) {
   waitForElement(locator);
   try {
     Actions a = new Actions(driver);
     a.moveToElement(driver.findElement(getLocator(locator)));
     a.perform();
   } catch (Exception e) {
     System.out.println("Elem not found: " + e);
   }
 }