selenium webdriver: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with

前端 未结 4 1114
名媛妹妹
名媛妹妹 2020-12-19 05:40

I am trying to click on the span with the text- clone concept. Following is the html

4条回答
  •  攒了一身酷
    2020-12-19 06:04

    Unfortunately Webdriver doesn't seem to be great at handling situations like that described in your questions. You have a couple of options though. Mock a click using Javascript:

    JavascriptLibrary jsLib = new JavascriptLibrary(); 
    jsLib.callEmbeddedSelenium(selenium,"triggerMouseEventAt", elementToClick,"click", "0,0");
    

    or

    ((JavascriptExecutor) driver).executeScript("arguments[0].click();", elementToClick);
    

    Or you can play around with using actions to click all of the elements in the menu chain. Unfortunately I have found this to be unreliable.

    I have a script which detects whether an element is in a menu chain and if it is clicks on them in the required order to finally click on the one the user wanted if you want it I can post it somewhere but it isn't pretty or short.

提交回复
热议问题