Automate change password Functionality using Selenium with Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back so in this video we are going to change the password of olx application so here i will enter one excel sheet here so i will add one more sheet and now you will be able to easily analyze how i did so in c2 i would create old password and second one is new password my old password is this one and i want to change it to another one so i will read this data from this sheet and then i will use it into my test so let's see how we can use it i will save this data and this is my reader so actual reader i will read again data from other sheet so i will copy the complete code here and i will create a different function so this is called the data for password change and here i will write the decorator so static method here i'm reading the book and my sheet is the next sheet so it will be at index 1 and here we will read old password and new password so i can write in this way old pwd and new pwd we are not doing for this user name we are appending on old password so we can use this logic for old password and here i can use old password here also called password so i'm reading data and here new password so i will copy this code and i will paste it here and i can make it new password and this is also new password and then you can see your new password this is also my new password so this is the data and let's say i will print your old password and i will print for testing purpose i'm just printing your new password and i will not use return as for now i will call this method and this is my method and if i will run this method i will say so i am able to extract the information so this data all password and new password and i can return old password all pwd comma new password here and i will delete those lines so just i'm reading the data from excel sheet again and now i will create the test here so there's a task module after login i will create again till here is fine so now let's say i will print something print start changing password so start changing password here and now we will locate the element so driver dot find element by id so i need to pass the id here so you can see after login you have to click on settings so if i will locate this element inspect it and you can see this is the setting and this is the class payment class this is the class of setting and the id is se account so i will edit it copy and i will paste here even you can use xpath css selector any selector you can use so i am using here id then i need to click on it dot click after that so you can see here manually i have clicked on settings then you will get another page so there is call change password there is a link so you can inspect it again so this is title change passwords you have to click here this is the class title id is this so i will use this id copy this id and i will use here time dot sleep for five second and then i will say driver dot find element by id and the id is change password and we have to click on it now time dot sleep for five second so here if i will click on this link you can see here so i have to click here change password after that you will get these values so i have to iterate old password new password so this is old password you can see this is auto value name class so there is a name attribute you can edit it edited html so let's say old password equals driver dot find element by name and the name is this and again i will find for the new password so new password equals driver dot let's see here so this is new password and here i will i treat it so here you can see this is the id input edit attribute i will copy this and here i can use find element by id find element by id here and paste this id now i will wait for some time and again there is another field so which is repeat new password so you have to do this again and this is also some id scch password and repeat new password so let's repeat password so this is editor.html and here this is id i will copy it so all element i have select repeat our new password so driver dot find element by id here i will pass the id so this is done here till now so you can see here new password this is done and now the next one is i will close this inspect element and here this is the change password we have to click on it so we need these values we can grab from here i will use timelessly first time dot sleep for five seconds and then i will grab from my actual reader so here 10. sleep and let's say old pwd comma new pwd because we are passing these values pnwd equals so this is actual reader old password and new password returns so here you can see in curls so my class is data reader so from data reader i need to call read data for password change so it will return two data and time dot sleep for five second and now we have to clear it so old first of all old password dot clear and now you send the data old password dot send keys here i will pass old pwd this is the old password and after that i will use new password here dot clear and i will send the key so i will wait for some time let's say time dot sleep for two second after that i'm clearing the new password text tool and then we are supplying the password so new password dot send keys new pwd after that there is a repeat also time dot sleep for two second and i'm saying repeat new password dot clear and then we have to pass new password dots and keys your new password we have to send here this is repeat and now we have to click on submit so time dot sleep i will wait for five second and then i will use driver dot find element so we have to locate the element this is the limit here i will inspect it so this is a change password button and here you can see this is a button and this is id if i will do edit html and this is id i can use so here i will use find element by id and here i'll pass the id dot click and after that i will wait for some time you can create the condition as well like you can verify the url title anything you can verify so it's up to you so let's run the program and see the output it's working or not it got maximized now and now it will click on my account and will supply the password and username from excel sheet so this is called data driven technology so here we are passing the data at runtime we are not fixing in program so here you can see i'm able to log in my account and after some time i will click on settings it's not clicking here there in here start changing password great so after this it will click settings and now after some time it will change the password getting some error so find element by name i think all passwords i'm getting error here so it's clicking there but i'm not able to find this element so maybe the problem is here i will load up old password so this is the old password field and i show here there is no id class is here name is here [Music] dave and here this is password so this is the div and this is input here i will use instead of css copy selector css selector here and maybe because of this problem so find element by css selector and i will pass here css selector and i will delete this name as well so now let's run again now it will maximize then it will click on my account this is fine now i'm able to login now it will click on settings password here we have to pass all password new password and repeat password there is a problem in chapter changing the password and passing some other thing here so just need to check so after click on change password find element by css selector so here we can cross check the things here so i will print here so print after click change password after getting all these things i will make here clear old password new password so here print get data from actual sheet so here this is fine after that all passwords and keys that's fine that's okay and here i can use find element by xpath file element by xpath so i will try with xpath should work okay so here i'll pass xpath so this is the old password here if i will hover on it and you can see here i will copy the x path and here i can pass it so this is the x path because i did not use that's what we can check also it's well it should work fine so find element by xpath here and i will pass the xpath of other field so this is new password so i would like to locate this element and here i will right click copy x path and i will pass your x path after that here also i can use find element by xpath and here i will pass this locator and my locator is xpath paste it and we are waiting for some more time so i can reduce the timing as well so that it will be good so i will wait for two second here i will wait for five second here and i will reduce the wait time so that it will be fast i think that's fine now now we can work again run it again now i have to click on my account so here i need to pass email address or phone number and the password it will click on settings change password so here i think after get data from excel sheet and here it's working fine now change password will click password change successfully this is called data driven approach for testing so you can create your own framework with data driven technology in next video we are going to work with pop-up window and keyword driven approach so we work with keyword driven approach and then we will work with hybrid approach thanks for watching
Info
Channel: Coding_Pandit
Views: 157
Rating: 5 out of 5
Keywords:
Id: MfW_CiwK_-Y
Channel Id: undefined
Length: 20min 50sec (1250 seconds)
Published: Thu Jul 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.