Невозможно перетащить изображение логотипа GOOGLE в Поле поиска из www.google.com . Пробовал с Acion Class, даже JavascriptExecutor.
driver.get("https://www.google.com");
// Element which needs to drag [Google Logo].
WebElement from=driver.findElement(By.id("hplogo"));
// Element on which need to drop [Google Search-bar].
WebElement to=driver.findElement(By.name("q"));
// Using Action class for drag and drop.
Actions act=new Actions(driver);
// Dragged and dropped.
act.dragAndDrop(from, to).build().perform();
/* JavascriptExecutor _js = (JavascriptExecutor)driver;
_js.executeScript("$(arguments[0]).simulate('drag-n-drop',
{dragTarget:arguments[1],interpolation:
{stepWidth:100,stepDelay:50}});", from, to);
*/
Я хочу перетащить и удерживать изображение Google, затем добавить изображение в окно поиска, но ничего не произошло.
Вручную, если я перетаскиваю, я нашел ссылку на изображение, например https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png во входном окне поиска.
Даже приведенный ниже код работает отлично, но не работает для google.com!
public class DragAndDrop {
public static void main(String args[]) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver","D:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://jqueryui.com/resources/demos/droppable/default.html");
Thread.sleep(10000);
Actions act=new Actions(driver);
WebElement drag = driver.findElement(By.xpath(".//*[@id='draggable']"));
WebElement drop = driver.findElement(By.xpath(".//*[@id='droppable']"));
act.dragAndDrop(drag, drop).build().perform();
}