Install Chrome Webdriver for Selenium | Python Selenium Tutorial [Part 1]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back everybody to another tutorial tuesday today i'm going to be showing you how to use selenium in python and actually this is going to be a multiple part series this is the first episode where i'm getting you started um we have a fresh environment installed and i'll be showing you how to get started working with selenium um so selenium is a testing um testing package for python and i've actually used it at work when it comes to quality assurance however a lot of people use it for web scraping as well or downloading files and very manual processes on the internet so it's great for those sort of things um so let's start by creating a new file and let's just call it start dot py um i would name it selenium however when you name files um like as a package that you're using a lot of times you run into issues so um this is a fresh environment for python so i don't have any packages installed if you see i'll do pip freeze um and you'll see nothing pops up so let's start by doing pip install selenium um and this might take a couple minutes oh but it's done now so um now if we do import selenium you can see um that it worked and also on pycharm you have the auto fill so you could see that there's the package icon and so if we finish that up and if we run it now we'll see that no errors um the package is working so with selenium you also need kind of a component to get on the internet whether it be like a driver for whatever browser that you're using okay and since i'm using google chrome i'm gonna need to download what is called chrome driver i will link this in the description but um google makes it publicly available and however you do need to make sure you get the right version so i would go into your settings over here and then click on the about chrome section and i'll tell you what version um i'm a little behind some on version 84. so if you click right here to download version 84 um it'll give you here i'm a window so i'm going to download the win32 package and then now let's take this chrome driver file and let's throw it in our file explorer where our file where our working python file will be um this way it syncs a lot easier with the driver if it's right next to the python script so now if we test this out um actually we're going to do a different import we're going to do from selenium import webdriver oh and i also want to make it clear i'm using chrome driver however if you were on firefox let's say since that's a different browser you would use what is called gekko driver i don't know if there's one for safari but i know chromedriver and geckodriver those were the closest ones that i've worked with um and also if you double click on this it will open up a command prompt window and it will say chromedriver was successfully started so that's how you know it's working and if it's not maybe try adding it to your environmental paths so if we do from selenium import webdriver and then do driver equals webdriver webdriver.chrome and let's run this we will see actually i'm working with two monitors so another window just popped up so you could see down below that another chrome window popped up and it you could tell it is because it says chrome is being controlled by automated test software um so it's successful now if that didn't work for you um and it's saying some issue with um can't find chrome driver or valid link you might want to do import os and then from there do os dot get cwd that means current working directory so it will pull us to where our python file is and then you're going to do slash chrome driver dot exe and this will work as well so you'll see right here it opens up a new chrome window and so that's another method if your path to your chrome driver isn't working um so let's try by opening up a website so if we do driver.get and then input a url let's do youtube so if we do that it will open up a new window and it will take a little bit to load but um you'll see that it loaded up youtube um so we got that working right and there's a few different options that you can add to chrome driver just to make it a little more user friendly so you can import what's called options so if you do from selenium dot chrome dot options import options and you want to just declare it options equals options open parentheses and then from here you can add in a few different statements so let's say options that add argument that add argument and then let's pass in a command so window dash size and then 1920 by uh 18 or 1080 1920 by 1080. um so now if we oh we have to do options so connects and then we also want to add it in here so we'll say options equals options and since everything is now connecting oh i'm looks like i'm getting an argument options object has no add argument attribute um so i think i spelled argument wrong yeah i did that's embarrassing um so now if we run it it will open up a new tab and if you see it's a lot bigger now because it's taken into account that scaling however you don't always need that um it's just some some features you can add in there with chrome options um so i think that's going to be it for this video next video i'm going to be showing you how to actually click on objects in selenium so if i open it up again and take us to youtube i'll be showing you how to click on say this video right here and you know maybe give it a thumbs up so stay tuned and that episode should be out in a day from now however if you're not watching this on the current day was uploaded um it already is and i'll be linking it at the end of this video so thank you very much if you found this video helpful please smash the like button on this and help out the youtube algorithm thank you so much and stay tuned for the next episode
Info
Channel: Stealth Rabbit
Views: 14,872
Rating: 4.9065418 out of 5
Keywords: selenium, selenium python, selenium tutorial, what is selenium, selenium webdriver, webdriver, chromedriver, chrome automation, Setting up Webdriver in Selenium, how to open chrome with python, selenium python tutorial for beginners, selenium web scraping, action chains selenium, send keys selenium, RAM Rabbit, how to use selenium, how to use selenium with python, selenium install, selenium step by step, install selenium, slenium, pip install selenium, selenium webdriver tutorial
Id: WnWQgUerR0c
Channel Id: undefined
Length: 8min 3sec (483 seconds)
Published: Tue Aug 04 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.