8

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.

WebDriver
  • 147
  • 4
  • 13

2 Answers2

11

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.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
VMykyt
  • 1,589
  • 12
  • 17
  • Thanks. I am still having issues with right click. The right click menu disappears as soon as it is displayed. I have implemented it like this: var context= action.ContextClick(gridElement).Build(); context.Perform(); I also used sleep so that the menu would not disappear, but thats not working. – WebDriver Dec 20 '11 at 11:48
3

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..

iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
vyas
  • 41
  • 1
  • 5