'How to simulate mouse click on blank area in website by Selenium IDE?
I want to perform mouse click on blank area outside a form in order to wake up the data traffic in some website by Selenium IDE. Any ideas?
I've tried to do click by x,y but it doesn't effective for my test case. The scenario is below:
- fill the email field
- click outside the form in order to make the client to send data request to the server for check if this email is already exist in the DB and then it does auto complete and enable the continue button.
Solution 1:[1]
You can use the command:
driver.findElement(By.xpath("//html")).click();
But sometimes it doesnt take blank spaces,
In such cases, use:
driver.get("//html");
Solution 2:[2]
The best solution is to just use the keyboard TAB key by executing the following statement.
element.sendKeys(Keys.TAB);
It will focus the next element - thus out of the field - and you will get your desired result.
Solution 3:[3]
'html' is a special element, what you want is 'body' (the first DOM element that is 'visible')
so please use the following (tested with Chrome confirme working with no problem):
python example
driver.find_element_by_xpath("//body").click()
Solution 4:[4]
Just click on another element on the page you are sure is present.
Browser.Driver.FindElement(By.Id("testtest123")).Click();
Another solution may be to invoke javascript removing the focus from that email field, it depends on the trigger you have set for the ajax to trigger.
Solution 5:[5]
Once email is filled, to click blank area, use this command.
driver.findElement(By.xpath("//html")).click();
It will click blank area.
Solution 6:[6]
I hope it still can help people, so i have the answer =) Selenium always throws exceptions on simple click if dropdown, field or whatever makes other buttons inactive. The way out for me was to use actions with pause. Here are some code rows from my example:
Actions actions = new Actions(driver);
actions.moveToElement(driver.findElement(By.xpath("your path")))
.click().pause('your amount of milliseconds').click().build().perform();
Wrap it into some function and there you go, you have a new clicker.
Solution 7:[7]
I need to click in a blank area in the react code.
The below code is fixed my issue.
driver.FindElement(By.XPath("//body")).Click();
Solution 8:[8]
You can click to outside of element using Actions
public void clickOutside() {
Actions action = new Actions(driver);
action.moveByOffset(0, 0).click().build().perform();
}
Solution 9:[9]
public void clickOutside() {
Actions action = new Actions(driver);
action.moveByOffset(0, 0).click().build().perform();
}
This is the perfect solution for this problem.
Solution 10:[10]
None of them worked for me. I solved the problem as below;
WebElement el = driver.findElement(By.xpath("//html"));
el.sendKeys(Keys.TAB);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
