how to resolve element click intercepted exception in selenium

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone so today we are going to discuss about how to resolve element click intercepted exception so let's get started first we are going to reproduce the exception element click intercepted so to reproduce the element click intercepted exception we have a script on the screen which is of a selenium so so what it does is it would not get to the google.com and then it types the channel name web text as soon as we type the channel name web text we can see the auto suggestions that's been available and then the script tries to click on the google search button which is actually behind this auto suggestions so it's here google search button but it's been overlapped by auto suggestions so that is the reason we are going to get the click intercepted exception so let me run the script to show you the same i'm running the script and you can see we have navigated to the google.com and it has entered the text and then there is an exception here you can see the click intercepted exception it's because we have tried to click on an element which is overlapped by the other element so how to resolve this so to resolve this issue the first try we are going to do is wait till the element is clickable so for that we have a explicit weight option in the selenium so this is how the code looks like webdriver wait so i'm going to place this code in the description please have a look and we need to pass the driver and timeout and then we should uh tell that should wait till the element is clickable so this is option you can see element to be clickable so we need to pass the element here the element is the search button google search button yes it's completed let me launch so in some cases it may work and in some cases the solution may not work so here you can see it's launched we have the exception so still the uh solution is not resolved if this uh if this explicit weight is not solving your click intercepted exception problem then we are going to try the second method that is using the javascript executor so when we perform a click operation using the javascript executor rather than trying to so what what the javascript executor does is it doesn't try to perform the operation on the ui level but it tries to perform the operation at the dom level so it's going to find the element in the dom and it's going to uh click click on that element so it doesn't matter whether an element is overlapped by the other element on the ua so i'm going to delete this way and add the code for javascript executer so you can see this is the code for javascript executor so first initializing javascript executor and then passing the parameters so we are telling them telling the javascript executor to perform click and passing the locator on which the click has to be performed so so since we have already performing click in this step i'm removing the last step which is also a click let's run this now you can see now the application google is launched and it has entered web text and you can see it has clicked on the google search button and that is the reason the results are displayed so you can see the issue is resolved and you can try this and let me know in the comment section if it really helped and and one more point i would like to add is if you are getting this uh element click intercept uh exception too many times that is you have resolved for one element and after performing uh action on two more elements again you are facing on the other element and you fix it that and again you are facing the same problem for the other element then you should check the compatibility then in that case the browser version you are using may not be compatible with the uh driver uh you are using so the for example if you're using uh maybe chrome uh version of 90 and if you are using a chrome driver which is a lower version like 88 they may not be compatible and you'll have these kind of issues so please uh watch for that as well yeah that's all thank you if you like this video please give me a thumbs up and please do subscribe for more videos
Info
Channel: WebTechs
Views: 2,082
Rating: 4.8571429 out of 5
Keywords: katalon studio, Selenium, Selenium tutorial, Selenium tutorial for beginner, selenium webdriver tutorial, element click intercepted exception in selenium, element click intercepted, org.openqa.selenium.WebDriverException, selenium Exceptions
Id: o81fkOGrVJc
Channel Id: undefined
Length: 6min 34sec (394 seconds)
Published: Wed May 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.