I worked professionally QA automation and we used selenium with Python bindings. But we’re required to use a framework servilely lacking in support and regular updates. I wanted to create my own framework.
Interface Drag and Drop (C#)
private void interfaceTreeItemDrop(object sender, DragEventArgs e)
{
Point targetPoint = interfaceTree.PointToClient(new Point(e.X,e.Y));
TreeNode targetNode = interfaceTree.GetNodeAt(targetPoint);
TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
String xpath = "/project";
String draggedXpath = "/project";
String[] targetPaths = targetNode.FullPath.Split('\\');
String[] draggedPaths = draggedNode.FullPath.Split('\\');
String targetName = targetNode.Text;
String draggedName = draggedNode.Text;
for (int i = 1; i < targetPaths.Count(); i++)
xpath += "/element[@name='" + targetPaths[i] + "']";
for (int j = 1; j < targetPaths.Count(); j++)
draggedXpath += "/element[@name='" + draggedPaths[j] + "']";
if (!draggedNode.Equals(targetNode) && !isParent(draggedNode,targetNode))
{
if (e.Effect == DragDropEffects.Move && dragType == "parent")
{
if(targetNode.ImageKey == "container")
{
String[] prevPath = targetNode.FullPath.Split('\\');
swapXmlNodes(draggedNode.FullPath.Split('\\'), targetNode.FullPath.Split('\\'));
clearTree();
dragType = "none";
reselectNode(prevPath);
}
//RULE #5
}
else if (e.Effect == DragDropEffects.Move && dragType == "sibling")
{
String[] prevPath = draggedNode.FullPath.Split('\\');
swapXmlSibling(draggedNode.FullPath.Split('\\'), targetNode.FullPath.Split('\\'));
String closestEle;
TreeNode parentDragged = draggedNode.Parent;
for (int i = 0; i < parentDragged.Nodes.Count; i++)
{
if (parentDragged.Nodes[i].ImageKey == "element")
{
closestEle = parentDragged.Nodes[i].FullPath;
if (parentDragged.Nodes[i].Text.Equals(draggedNode.Text))
break;
}
else
{
//if (parentDragged.Nodes[i].
}
}
//if(draggedNode.ImageKey == "element")
reselectNode(draggedNode.FullPath.Split('\\'));
List newNodeList = new List();
clearTree();
dragType = "none";
reselectNode(prevPath);
//RULE #7
}
targetNode.Expand();
}
}