2021年4月7日星期三

Selenium Webdriver Python code explanation needed

Please provide me some basic idea about the code. I am new to Python. I went through some tutorials and everything is related to Selenium JAVA where they mention webdriver as an Interface, whereas in Python webdriver is called as Module.

import time  from selenium import webdriver  driver = webdriver.Chrome("../drivers/chromedriver.exe")  driver.set_page_load_timeout(10)  driver.get("https://google.com")  driver.find_element_by_name("q").send_keys("Automation step by step")  driver.find_element_by_name("btnK").click()  time.sleep(2)  driver.close()  driver.quit()  print("Test Completed")  

As per my understanding, we are importing webdriver module from the selenium package. We created an Object called driver.

Is Chrome a class of Webdriver Module? Are we creating an object of Chrome using driver = webdriver.chrome() ?

I used Pycharm and tried to check what is happening inside Chrome class and Get method. But I didn't it clearly. Is Chrome Class defined in the Webdriver Module? I am confused if the methods used in the above codes are Webdriver methods or Chrome Class methods.

https://stackoverflow.com/questions/66995811/selenium-webdriver-python-code-explanation-needed April 08, 2021 at 08:27AM

没有评论:

发表评论