[Selenium]重写拖拽dragWidgetToElementContainner()

public void dragWidgetToElementContainner(String widgetName, String targetPosition){

		WebElement widgetIconEl=page.getWidgetIconInDockMenu(widgetName);

		((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", widgetIconEl);

		WebElement elementContainer=null;

		if(targetPosition.equals("left")){

			elementContainer=SeleniumUtil.waitForElementPresent(driver, By.cssSelector("div#wsp-wrap-body div.x-box-target div.x-container:nth-child(1)"));

		}

		if(targetPosition.equals("right")){

			elementContainer=SeleniumUtil.waitForElementPresent(driver, By.cssSelector("div#wsp-wrap-body div.x-box-target div.x-container:nth-last-child(1)"));

		}

		WebElement dropableEl=page.getDropableIconInWorkspace();

		this.dragAndDropToElementContainner(driver,widgetIconEl,dropableEl,elementContainer);

		

		SeleniumUtil.waitUntilAllAjaxRequestCompletes(driver);

		this.waitForLoadingDoneInNewWebPage(driver);

		SeleniumUtil.sleep(2);

	}

 

public void dragAndDropToElementContainner(WebDriver driver, WebElement dragableEl, WebElement dropableEl,  WebElement targetEl){

        Actions action = new Actions(driver);

        action.clickAndHold(dragableEl).build().perform();

        action.moveToElement(targetEl);

        action.release(dropableEl);

        action.build().perform();

    }

 

你可能感兴趣的:(selenium)