in commonly used browsers, (Chrome, Firefox and IE), drag page elements to the input box (< input type= "text" / >);
- if the element being dragged is a picture (), the href attribute value of the picture is automatically populated in the input box;
- if the element being dragged is text (< span/ >, < p / >.),), the contents of the text are automatically populated into the input box.
however, the above function cannot be achieved by calling the relevant API, of WebDriver to simulate the above behavior.
related codes
Actions builder = new Actions(driver);
//use dragAndDrop
builder.dragAndDrop(source, target).perform();
//use moveToElement,clickAndHold,release
builder.moveToElement(source, 10, 10).clickAndHold(source);
builder.moveToElement(target, 10, 10).release(source).perform();
none of the above methods can achieve automatic filling, how to use WebDriver simulation to drag and drop page elements to the input box?