WebDriver
WebDriver

Reputation: 147

Right click and Drag and drop using Selenium webdriver

I am working on a qa automation project using Selenium webdriver.

I need to perform drag and drop on a telerik rad grid for reordering columns and then right click on the grid to save the changes made.

Is there any way i can achieve these using selenium webdriver ?

Thanks.

Upvotes: 8

Views: 9074

Answers (2)

vyas
vyas

Reputation: 41

you can click in same action when it disappears as soon as it appears... just like

action.ContextClick(element).Click(x axis, y axis).build.perform();

it will works..

Upvotes: 3

VMykyt
VMykyt

Reputation: 1629

For drag and drop you may try:

using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Firefox;    
using OpenQA.Selenium;

RemoteWebDriver driver =  new FirefoxDriver();
Actions action = new Actions(driver);
IWebElement sourceElement = FindElement(By.Id("id1"));
IWebElement targetElement = FindElement(By.Id("id2"));
IWebElement gridElement = FindElement(By.Id("grid"));
action.DragAndDrop(sourceElement, targetElement).Perform(); //drag&drop
Thread.Sleep(500); //if necessary
action.ContextClick(gridElement).Perform(); //right click

or you may use JavaScript for this.

Upvotes: 11

Related Questions