Selenium WebDriver 没有点击 Google 模拟器中的按钮

Selenium WebDriver doesn't click on a button in Google Emulator

我正在使用 Google 模拟器编写自动化程序

    Map<String, String> mobileEmulation = new HashMap<String, String>();
    mobileEmulation.put("deviceName", "Google Nexus 5");
    Map<String, Object> chromeOptions = new HashMap<String, Object>();
    chromeOptions.put("mobileEmulation", mobileEmulation);
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
    webDriver = new ChromeDriver(capabilities);

当我尝试点击手机屏幕上的某个按钮时,它没有任何反应,也没有错误信息,测试通过。

    WebElement close = webDriver.findElement(By.id("closeIFrame"));
    close.click();

任何想法。谢谢

尝试在这些行之间引入一个等待。

WebElement close = webDriver.findElement(By.id("closeIFrame"));
wait for a short while.
close.click();

偶尔会出现这种情况,你的代码速度太快,网页跟不上。

尝试 "hover" 在此按钮上然后 "click",

使用链式操作,这里,http://selenium-python.readthedocs.org/en/latest/api.html#module-selenium.webdriver.common.action_chains