How to Handle Element is Not Clickable at Point Exception in Selenium Webdriver

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey hi everyone welcome back to another video learn - automation calm this is Mukesh today I have a very interesting topic to cover recently I was facing this issue multiple times twice thought to create video on this so today we'll talk about how to solve this element is not clickable exception in selenium so let's get started with high-level agenda so we will talk about what this element is not clickable at this point in selenium so this is just an exception so we have different scenarios when it comes and what are the different solution to handle this then I already published for solutions on my blog but I have one more solution which is more reliable and it's very easy as well then or to avoid the code again and again will create a library for this and will add into a framework so what is element is not clickable at point exception in selenium soul anyway always try to click on element on middle of the limit so I will show you through example as of now just read this theory part first so for some browsers you will not get the expected behavior because each browser have the different implementation so sometime click operation will throw you element is not clickable at a specific coordinate it will also provide you x and y coordinate so as per my experience it mostly comes with Chrome and Safari so I will show you now it doesn't come with Firefox and other browsers it mostly comes with Chrome and Safari so the solutions which I have proposed in block you can find the link in the description and the easy one is you can try a different XPath or else you can try using mouse over I will show you now one by one so let me go back to the Eclipse but first of all let me show you the scenario so when we go to this login dot yahoo.com you can see this one is small checkbox so there are two ways to uncheck this either you can click here so it will cut uncheck or you can click here as well so either you can check click on this checkbox or click on this text so both the ways it works in Firefox but if you try to click directly here in chrome it will throw you exception let me create it so I will create a class and class name I will give young male check I will take public static void main and I will quickly write the code to start the browser so webdriver driver equal to new Firefox driver I am using gecko driver here so I have already placed gecko driver in one specific location so it will not ask me again and again let me directly start to the application application I will provide here now let me provide implicit weight as well so that I can avoid some unnecessary sink issues implicit weight I will get 30 second even if you don't give it will not make any difference as a flaw because we are working on single web element so what I will do I will find that element and finally I will click very straightforward so if you simply right click and say inspect in fire path just inspect this checkbox so you can see even with Firebug it is not allowing me to inspect it is not going here but if I forcefully see the IB is persistent right if I put mouse over then only it's getting highlighted but if I put directly mouse here it's not dilating so let's take forcefully this ID ID is persistent here you can take the label S Pen but let's try with ID now you will get some interesting point here so let's run the scenario by default it will be unchecked so it will click on it and it will check this particular check lock so it look started and it uncheck now right now let's try to run the same scenario in Google Chrome and you will see the different result so I will copy paste here and this time I will say yahoo mail check chrome I will make a small change here in spite of Firefox I will directly write chrome driver and let me run the scenario now started and you can see it's not clicking it's waiting for that element since I given 30 second and it is still not clicking here and yes here you go you can see a long exception here so whenever I get this kind of exception don't worry about it just start in the reverse direction you can see the main exception is coming yahoo mail check chrome line number 18 so if I click here it will redirect me here and if I check the exact test section in the reverse direction first it will call the remote web element and so on and finally the exception will be element is not clickable at this point so this is the X&Y coordinate now it says other element would have received the click so it says when you are trying to click on that particular checkbox text and then click on it still it should work so you can see I have a label here and with this ID so this ID I will not take because this very dynamic in nature so I will try to identify this using this text so you can see the text is coming here so I can directly ident by using this text so I will write my own XPath I will say search for a label where text equal to say sign in and you can see one matching node is coming so what I will do I will take this XPath and now I will try to click OK so now you will see it will not throw any exception it will click directly so it started another instance and you can see it clicked here so it got unchecked without an exception it is working so you can see using different kind of XPath or you can say some relative XPath will solve this issue but if you have a requirement that know you have to use the ID only then yes I have one more solution so let me create a copy again and this time I will show you through actions class and this is the reliable solution because even if we change the browser Safari ie Chrome I and other browsers it will remain same so what I will do I will still take the ID but this time we have to use actions class so I will create object of actions class I will create object so what exactly I am trying to do let me show you manually first I will put mouse over first then I will click this is the scenario which I am trying so using this actions class we can perform move to element which is nothing but your mouse over so now you just see is very interesting point here it will give you very information like it will move the mouse to the middle of the element so this is what we want right now and where we need to put mouse over so I will say driver dot find element by ID I will use the same persistent ID and now I will click so first mouse-over then click and since we are using more than one operation so we need to call dot bill dot perform if it is only one operation you can say dot perform but since we are using mouse over and click both we need to call dot del dot perform now even if you change the browser it will work so let me quickly run this test and you will see it will work without any exception so another browser started and yes you can see it worked so this is how you can try different scenarios I would recommend you to create library for this so I already have one library folder created over here so I will to click create one class called click element and I will click on finish let me create one small library public static void click and here I will copy paste this code so you can see here two things are dynamic so you need ID so let's make this method click by ID so what we will do we will accept webdriver as an argument I will say el driver means local driver and I will accept ID as a parameter so whatever driver I will get I will pass here and this ID is dynamic now so whatever ID user will pass it will come here so now it become dynamic so as of now I created one library for ID sorry when library for ID locator if you want you can create multiple methods like click by expert click by CSS and so on now it's time to call this library so if you don't want to use this what you can do just call click element dot click buy ID pass the driver and pass the ID so driver we already have here an ID I will pass this one and let me remove this code right now the code looks also find it says I guess we just changed something here click well D this allow me a moment should not throw any error let's repeat this again click element dot click by ID pass the driver and ID they some other I should don't worry click by IDs and de fight for the type click element just one minute is seen some temporary ratio yes since eclipse is an open source of some time you will get some unnecessary exception and problems now let's run it again functionality-wise nothing will change because we have not changed anything only we have structured of a code this so now you can see it working fine so like this you can create multiple methods and you can call them I already have different solutions so you can also try to click here you will find the different solution on my blocks so you can try that as well so I will share this link in the description so you can go ahead and check I have already shown if you are still not getting the solution you can try using X and y coordinate you can try to update that chrome version and so on okay that's all I have for today so this is very good thought which I got from Internet gaining knowledge is the first step to wisdom sharing it is the first step to humidity so thank you so much for watching this video if you still have any doubt just do the comment below or you can send me email s will Mukesh at that learn - automation comm if you like this video please share with your friends subscribe to my channel and hit the like button below thank you so much have a nice day
Info
Channel: Mukesh otwani
Views: 95,732
Rating: 4.7916665 out of 5
Keywords: Selenium, Selenium Webdriver, Test Automation, How to Handle Element is Not Clickable at Point Exception in Selenium Webdriver, Handle exception in Selenium, Selenium Webdriver tutorial
Id: XNwcGNLk3cE
Channel Id: undefined
Length: 14min 22sec (862 seconds)
Published: Mon Nov 28 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.