 Hello, my name is Daniel Andrei and I'll be your instructor for this Selenium course in Excel. Selenium is an open source automation framework that allows you to automate tasks in a browser. In this instance, we'll be using Chrome browser. So let's get started by going to the Chrome Selenium basic page. So this is the first result, github.io. Then we click on Veon github. Then on this, on releases here, and then we click on this execute file. Next we are gonna see the version of Chrome about Chrome version. We see here that we have version 113.0. We go to search for Chrome driver, the first result, Chromium and here based on our version we select the Chrome driver. So it's 113. So we click on this. Here we select the operating system. In my case it is Windows. Next I'm gonna install this. We first install the Selenium basic. Here you can select your browser if you want, but for now we're gonna use Chrome. Here is the folder. I'm gonna copy this and install. Finish. Next we extract this file. We place it in the same folder where we installed Selenium. Click on it and select folder extract. It says that there is a radio file there, so I presume that the on the github release page it has already a Chrome driver, but to be sure that we have the correct version we're just gonna release it, replace it. Okay. Next we need to put the Selenium Chrome driver into the environment path. So we're gonna search for environment variables. So we're gonna click on edit on this environment variables. Under system variables we're gonna go down on path, double click and here I have an older version. So I'm gonna delete this one and then I'm gonna click on new and paste what I just copied. I'm gonna click okay. Okay. And okay. Next I'm gonna create Excel document. Let's name it automation Selenium. So for this to work, we're gonna need the developer tab. So if you don't see this, just go to file, options, customize ribbon and in your case this developer tab is gonna be on tick, so just tick it and then click okay. On the developer tab just click on visual basic. First we need to add the reference to the Selenium basic. So on this page window we're gonna search for Selenium. You can scroll or you can just click s on your keyboard that you bring you down to the s and then we see it here and make sure that this is pointing to the right directive. So in my case it's pointing to Selenium 64. 64 stands for your operating system bytes. We click okay. Then we insert a module and we write public sub open page. So just to test it. So I'm gonna put deem boot as web driver. So we're gonna put boot that start and in brackets we're gonna put, we're gonna select the browser. So in this case is Chrome comma and here we put the link what page we want to open. It needs to start with HTTP or HTTPS. Let's go to Google and let's put, let's load the page because this only opens the Chrome browser. It does not go to this page. So to do to go to the page we go boot.get and we put it like this and a slash. So this is gonna add a slash at the end of this. It's gonna be like this and let's wait a bit until it closes. Wait one second. So one thousand is one second and then boot that quit. Let's run this. So we have a problem. Oh, I forgot to put new here. So I'm gonna press this new. It's gonna make a new element. So if we run this, opens Chrome and then it closes it. So it works. Thank you for watching. Please leave a like, a comment and if you want please subscribe to the channel. Hello everyone. This is just an announcement. Hello, today I'm going to show you how to do automation in Excel using Selenium framework in visual basic application. So the goal for today is to accept a cookie pop-up on Google.com. So let's start Excel, click on developer, visual basic and first we install references. We tick some boxes. Click as. Selenium, okay. Insert, module, public, sub, open page. So we do dim, boot as new, web driver. So this is what stands at the core of Selenium. This is what makes it tick, the web driver. So we need this. And then to start com you do boot.startchrome. And then we add the URL, http.com. So you always need HTTP added or HTTPS. Now, if we run this, it's not gonna do anything. It's just gonna open Chrome. It's not gonna go to this page. Because we need to load it. So we do that by using boot.get. Now it's gonna load it. So let's see what it does. And it's coming here and then it closes it. So two problems. We need to maximize the window and we need to make it not close so fast. So we do boot that window.maximize. And we do boot.500. Actually, let's put 200. And we put boot.quit. Run this. Voila, we get to the page. Okay, so now we have this. I'm gonna put this as 40 seconds. So each time you go to a page, it downloads on your computer from the server, a copy with all of the elements of the HTTP HTML. So to access that, you click on F12. This opens up the console tool and then you click on this tool. And here, this way, in this way, you can select the elements. You can select this. And you can see here that each element has a class and a name. We cannot use the class, but we can use something else. We click right and then we go to copy and then copy full path. I'm gonna show you how to use the class, but we cannot use this class because it has a space. It has multiple classes. So I'm gonna change these to 10 seconds and I'm gonna add some waiting time here. So we're gonna do button equal dot find, so you can find an element using multiple ways by class ID, CSS, link, name, but for now we're gonna use xpath. We paste this here while we copy it. And we're gonna declare this at the top. So we're gonna put dm as we do it selenium dot web element. Now we put here cbutton dot and now we do boot dot cbutton click. So this is gonna click it. Now, if we didn't have this wait, this code would run a lot once. That means that the page isn't loaded yet and this will run, which will give an error, saying that we cannot find this element because this element doesn't exist. So that is why we wait three seconds. So this code executes and after three seconds when the page loads, this code runs and is. Now we add this text area. So it has a class, so we copy that. And now we do, we wait again, set text equal boot that find element by class this time. Copy this from here, paste it here, copy this, click. And then to add text we put boot dot send keys. So it's gonna enter the Amazon and next I don't think that we need to wait for this. Amazon and then so we're gonna click on search. So we're gonna has, so this let's do it again. So we copy that, I'm gonna paste it here. We just copy this and change this search button, copy this, paste it here. We're gonna wait for this one. Boot that, wait one second, do this. Click and hold, move to, oh, we're gonna click on this one. So this goes here and this goes here. Now let's see how if it works and it works. So let's continue from where we left off. So we are on the Amazon. We want to click on the Amazon link. But firstly, we have some code that is a bit redundant here like this. So I'm gonna show you some stuff. So we declared the C button here as an element. So what we can do, we can comment this, we comment with this. So we put C button. C button dot click. Here we declare we need another one. So here we declare the input and then the search. Here I'm gonna put it like this and this is the same. And then I'm gonna just use the text. I'm gonna put dot click. So we don't need this anymore, mouse dot move to click. And here as well. So put it like this. Search. Yes, search button dot. But before this, I have to put hold on input, input text dot click and hold. And then so let's see how this works. We have a problem, element not visible. So input text click and hold. So I think we need to put some weight in time here. That's why it isn't finding this, I think. Oh, I know, I know what's going on. So we didn't put here input text dot send keys Amazon. Now it should work. Yes, and it works. But there is one more thing that we can do. This code here, we can remove this because there is a method. So we can put input text dot submit. And now we don't need this anymore. I'm gonna comment this, comment this as well. So you see, now we want this, but we OK, we want this to click on. So we do it, we click on F12, we select it. And we see here that this has a text in it. So we copy this, close it. And then we put here find element by partial link. Actually, I think we can put find, find element by link text. And we put dot click. So let's see, OK, so this doesn't work. So let's put it the other one, partial link. So we are on Amazon page. So now we want to click on this. Can we do that as we get the input and we get the class. Actually, let's get the full expath because it's easier that way. So we wait for the page to load. Wait two seconds. Then we put put dot find element by expath and dot click and is gonna click it. And then I want to click on this. Now that is a lot I want. I was hoping to see, yeah, we have here a hover. If we hover is gonna appear this. So, OK, so let's continue from where we left off last time. So we're gonna move the mouse to this button, which is and then hover over it and then click on this link. But you can see here that we do not get any option for this. We can see that the class changes. So this is something that is done using JavaScript. And we cannot get the class because this changes it. And also there is some space between the classes and you cannot use that. But we can use the text. So find element by partial link. OK, so first let's get the ID for this, the class. So let's do boot. Let's set a variable set hover account equal boot dot find element by class. Then we're gonna do boot dot mouse dot move to hover account. So this will have this will be like a hover. So it's gonna move the mouse to that button. Then we're gonna do boot that find element by partial link. Element is this. So we're gonna copy it. We're gonna click it. So let's see if this works. And we've got an error. OK, let's put some waiting time here. Maybe that's the problem. OK, so it's not finding it. Let's put here that click. And let's do it again. I think there is a problem with this button here. Let's get this copy and here actually we don't need this here. Let's do it again. Keeps clicking on this. OK, maybe there is another class here. So let's let's see. Yeah, this is this he has not line two is clicking on this instead of clicking on what we want. So let's go back to this. We can get the full expat. The bug. And then do this and it does it. But it's clicking on sign in here somehow. Instead of clicking on this, we don't need to sign in to click on that. Let's copy this again. Let's demo this because it should only be moving to that, not clicking on it. OK, so it's done it. Next, let's see what we should do next. Maybe change this. So let's look here search. So we see that we have some options here. I'm going to show you how to select an option. So let's get the ID from this copy and this. So here I'll put set drop down list. Call find element by ID and then we do it like this. We drop and we do boot that mouse click. No, let's let's check again. So it's yeah, we need to click on it. We first move to it, click, then we do boot that actions. So we first we need to declare this at the top. So let's just change this with this. And then we do it like this as select dot. And we have some options here, select by index. Text value. So we are going to select by value as we've seen that we have some string, some naming. So let's select this one computers. Just copy this and then we put it here. So let's try it. It's a drop down list. OK, so changed it. OK, thank you for watching. I'll be seeing you in the next video. Please leave a like a comment and if you want, please subscribe. In this lesson, I'm going to teach you how to get the title of a product in Amazon and the price from here. OK, let's get the URL. We're going to add it here and let's copy the title. So let's get it by the ID. X dot. Not text, this should work. And then I want to debug this. I want to print it. So we're going to put that print. We're going to put this there and let's let's open the debug window. Now let's look at the price. So it's a span. So we can do copy full expat. I'm going to do the same thing here. So let's change the price. And here let's put title. Copy this, paste it here. Rise the text. Remove this. And this and let's run this and we got it here. Now, if we want to place this into a cell instead of printing it into the debug window, we can do this. So we're going to put range a1 dot value equal title dot here as well. We're going to put a2. Let's comment this and let's run it and we have it here. Thank you for watching. Hello. Today I'm going to show you how to send emails in gmail.com using automation in Selenium. So we see here that we have three emails and this code is dynamic. So if you add another email, it's going to send that email to that address as well. So it's going to send this hello and this, I thank you for your email as the body. So let's look a bit at the code. So here we declared some variables, we declared some ranges, we declared some elements. Here we start Chrome, we insert the page, we load the page, we get the main email that is going to be used to log in from cell a1. Here we get the emails. So from a1 to a and last row. So this code here checks what is the last row with data. Then we get the subject and body. Here we introduce the main email into the email field. We click on next. We wait for a bit for the page to load. We enter the password. Then we click on next. Then when we get to the gmail, we click on compose email button. Then we declare, actually I forgot this step, so we are going to loop over those emails. So for each email in that range is going to send an email. Okay, so we click on email that field, we enter the cell value, what email it is in this range, we release it. Then we click on another element on the page because there is a popup that appears and it kind of messes up with the program. So we click on search, then go back to the subject box, we enter the subject value. Then we find this, this I haven't shown yet, it's find element by CSS. So you find it by that attribute. I'm going to show you how to find it. Important is that it shouldn't be like these two words. If it's two words, I don't think that it's going to work. Next, you click on it, no, you click on it. The program clicks on it. Then it waits. Then it adds the body value. And then it clicks on send. And then it goes again at the top and adds the other emails. So let's start this. Let's maximize email added, password added. So it's going to click on this compose when the page loads. Okay. You're going to click on search, back, test. And now you see this is send it. Now the second email and the third email. I'm going to delete or just leave it there. Let's add another email here. John Tom at gmail.com. Just to see that it works for this, for a new email as well. And let's run this. Just going to delete these ones. So the first one, the second one is not going to show it because these are fake addresses, email addresses. And the third one should show now. I think there has been some problem. Let's delete this. This is the first page. Let's click this and try again. Let's see what email field that click. Let's delete. Let's try it again and see what's going on. Maybe because I was deleting those stuff, it impacted the code. Yeah. So it works. Next, I'm going to show you how to find the element by this attribute. So I'm going to stop the code. Okay. So find the element by CSS and the attribute is role. And this is the string text. So you will notice that on the gmail website, these elements, IDs and classes change after some time. So if you copy this ID after five or 10 minutes, it's going to change and the code won't run anymore. If you do copy and copy expat, it's going to be the same. So what you can do, you can use a find element by CSS. You see the attribute here role and the text. You cannot use, as far as I know, this one like this, because it has a space message body that won't work. This one, same button. It was a bit tricky with this one as well. So we click on it. You will see we get this element. But I didn't choose to use it because I couldn't make it work. So I choose to click on the class on the element parent. So on this DC class. And it worked. I could have used the role button, but I didn't. I choose to do it this way. It could have worked that way as well. Most likely, yes. Okay, that's all. If you have any questions, please leave a comment and I will respond as fast as I can. And thank you for watching. In this lecture, I'll be teaching you how to send an attachment with the emails that we were composing last time. So we can see here. Let me move this here. We have an attachment button. And if you click it, it's going to bring us to this folder directory. So I want to add the screenshot, this screenshot. So how we can do that is if we search for the element using the developer tools and if you click on it, it brings us this element, this div. But we do not want to add the screenshot to this element because it's not going to work. This is just an element. To add files to a website, we need to... The website needs to have an input file. And the type needs to be filed. You can see that we cannot see it on the webpage because it's hidden. So if I make this bigger, you can see here that the height is zero. So if I put this as 10 and this the width as 10, I remove the opacity. I'm going to put this as 100 pixels and this as 10. And the display as block. And let's add the background color. So background color. And let's add it as this. Let's see here. It should show somewhere. Now if I go down a bit, now it disappeared. Where is it? Here. I think we need to change this to one. Position over for hidden 10. Let's see here. I cannot see it. Let's make it bigger. Yes, so now you can see it here at the bottom. Let's move it a bit. Let's add minus. Because it is in that div, I cannot move it up. But you can see it here, this button. This is an input field. And it's hidden. So when you click on this, this is click on. So if I click on this, it brings up to the same interface, the same window. Now what you need to do is just copy this. So we can find it by a full path. If we click on it, we find it like that. It doesn't matter if it is hidden. We cannot see it. It has just, as us, we cannot see it. But it is on the web page. The code is still there. So let's open this. This. Why is this one? So if we go to this. Okay, so at the bottom of the script, I added this line. We find the element by CSS. We find it by input. The element. And then the type file. And then we send the keys. We do not click on it. We send the keys. So we send the... So here you can put wherever you put your image or file. But it needs to accept the type of file. So, yeah. Sometimes you will see accepted file type. And you will define what kind of file they can accept for that input type. So you added it. And now it's sending it. Send one. So that's how you do it. In this lesson, we're going to learn how to interact with the console in the developer tools. We can use the console to find... To run code and to find elements. Using document that query selector or get element by the name or class. We're going to use the element from last session. So the file input. We have it here. And we go to console at the top. And we write document dot query selector. This finds elements by CSS. So CSS is the attributes and the styles. So we put input file input type equal. I have to put double codes here because I put at the start single codes file. And it finds it. We can find this element by the name as well. Dot get element by name. Name file data. And it finds it as well. And if you expand this array, we can see that it finds only one element because here is zero. And the length is one. We can find elements by class. So let's choose a class. I'm going to choose this one. And here we can see that it found seven elements with this class. Usually in web development, we use classes, class names for multiple elements. It shares the same styles, the same kind of code, the same code for the class. And on the other hand, elements by ID are only used once. This is the norm. Of course, there are exceptions to this norm. So if you find an element with an ID, find this one. You can see the class and this AC4 here. And put here. And we find it with the class. So it can be quite useful using the DOM. That's what this is called. Okay. So thank you for watching.