Selenium webdriver click vs action.click whats the difference?

前端 未结 2 1893
攒了一身酷
攒了一身酷 2021-01-05 01:17

I was struggling with a popup dialog in a website I\'m automating, for some reason it wouldn\'t click a button in the dialog but interacted fine with everything else fine.

2条回答
  •  醉梦人生
    2021-01-05 02:14

    I am not sure about your specific case, but there are several differences between WebElement click method and Actions click method. Actions' click is a lot dumber, it pretty much just sends the click event to the element (location) that you pass in. It does not care about the element, it just does the click and moves forward whereas webelement click is a blocking call (not always, check the references) and it also has preconditions like the WebElement to be clicked must be visible. Also, webElements' click is a void method, actions click returns reference to the Actions you are using. For more information check here and here.


    edit. Looking at the markup you posted, and it can be totally wrong as I am not a boss on bootstrap CSS, the modal hide fade in and especially the fade in part there looks suspicious. Are you sure that when you send the webelement.click(), your element is in clickable state? What happens? Nothing? Then again, if the actions click is reliably working, why not just go with it, I mean, if something works, why fix it?

提交回复
热议问题