Selenium / Firefox: Command “.click()” doesn't work with a found element

后端 未结 6 2235
陌清茗
陌清茗 2020-12-14 08:17

I tried to find a solution to this thing and I spent a lot of time, but it is almost imposible to me to do that.

The matter: I am using Selenium with Java in Firefox

6条回答
  •  遥遥无期
    2020-12-14 09:14

    Finally I found an answer that works with Firefox as well as Google Chrome.

    WebElement we = this.driver.findElement(By.id("size-btn"));
    
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("arguments[0].click();", we);
    
    waitForElementPresent(By.xpath("//div[@id='size-btn' and contains(@class,'opened')]/span"));
    

    Thanks for reading me.

提交回复
热议问题