Answer the question
In order to leave comments, you need to log in
Why did Selenium WebDriver redirect to Google search page?
Remembered Selenium, decided to practice drag-and-drop on this page: https://www.seleniumeasy.com/test/drag-and-drop-de...
Actually, here is the code that I'm trying to implement my plan:
public class DragAndDropDemoPage extends Page {
public DragAndDropDemoPage(WebDriver driver) {
super(driver);
navigateTo();
}
@Override
public void navigateTo() {
driver.get(Urls.DRAG_AND_DROP_PAGE_URL);
}
public void dragAndDropElementWithIndex(int index) {
List<WebElement> elements = findElementsByCss("span[draggable=true]");
new Actions(driver).dragAndDrop(elements.get(index), findElementByCss("div#mydropzone")).build().perform();
}
}
public abstract class Page {
WebDriver driver;
public Page(WebDriver driver) {
this.driver = driver;
}
public abstract void navigateTo();
protected WebElement findElementByCss(String cssSelector) {
return driver.findElement(By.cssSelector(cssSelector));
}
protected List<WebElement> findElementsByCss(String cssSelector) {
return driver.findElements(By.cssSelector(cssSelector));
}
protected WebElement findByXpath(String xpath) {
return driver.findElement(By.xpath(xpath));
}
}
Answer the question
In order to leave comments, you need to log in
So everything seems to be logical) Selenium does not work well with html5 drag-and-drop, but the motion event is still generated (most likely))).
And it goes to Google, because. your cursor is physically located on the search bar of the browser (I will assume that the IDE start button is in that place). So you took an element, js calculated the coordinates, they ended up in the search bar, and threw it there, a search took place
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question