是否有一些简单的拖放功能的工作代码?
我在这里尝试了所有可能的代码示例,但在Visual Studio(C#)中都不起作用。
WebElement firstdoc = driver.FindElement(By.XPath("//*@id='body']/section/div/div[5]/ul/li[1]"));
IWebElement Fundingfolder = driver.FindElement(By.XPath("//*[@id='body']/section/div/div[3]/div[1]/div[1]/div[1]/div[1]"));
IWebElement secdoc = driver.FindElement(By.XPath("//*[@id='body']/section/div/div[5]/ul/li[1]/div[1]"));
IWebElement Incomefolder = driver.FindElement(By.XPath("//*[@id='body']/section/div/div[3]/div[1]/div[1]/div[2]/div[1]"));
Actions Builder = new Actions(driver);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
Builder.MoveToElement(firstdoc);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
Builder.ClickAndHold(firstdoc);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
Builder.DragAndDrop(firstdoc, Fundingfolder);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
Builder.Release(Fundingfolder).Perform();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
答案 0 :(得分:0)
IWebElement drag = driver.FindElement(By.Id(id));
IWebElement drop = driver.FindElement(By.XPath(xPath));
(new Actions(driver)).ClickAndHold(drag).MoveToElement(drop).DragAndDrop(drag, drop).Perform();