Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
695 views
in Technique[技术] by (71.8m points)

c# - How to avoid MouseOver on Selenium Click()

In one of my Selenium test cases, I have the problem that there are MouseOver effects that I don't want to have. This is what I do:

  1. Click on the "login" button (top-right of the page)
  2. Wait for page to load
  3. Click on the "buy" button in the search results (middle-right of the page).

The problem is, that there is a "shopping basket" link with a MouseOver effect right in the middle between "login" and "buy". So when I call Click() on the "login" button and afterwards on the "buy" button, I trigger the MouseOver, which opens a small preview of the shopping cart, which hides the "buy" button behind itself.

This goes for Firefox and MSIE. In Chrome, I don't have this kind of effect.

Any idea anyone?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As Andrew is right. If it is not happening manually then it should not happened here as well.

You can also try to click using JavascriptExecutor

WebElement element= driver.findElement(By.xpath("Your Xpath"));

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);

Below is some example that how you can do it using C#

Execute JavaScript using Selenium WebDriver in C#

Hope it will help you :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...