问题
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.
回答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");
回答2:
'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()
回答3:
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.
回答4:
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.
回答5:
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.
回答6:
Once email is filled, to click blank area, use this command.
driver.findElement(By.xpath("//html")).click();
It will click blank area.
来源:https://stackoverflow.com/questions/27966080/how-to-simulate-mouse-click-on-blank-area-in-website-by-selenium-ide