Author - StudySection Post Views - 198 views
Selenium

Selenium Web-driver Commands With Python

Opening URL

The URL in Python Selenium is opened or fetched using the driver.get() method of the selenium module.

Time Delay

is a function used to delay the execution of code for the number of seconds given as input to time.sleep(). The time.sleep() command is used to sleep the window. You can use the time.sleep() function to temporarily halt the execution of your code. For illustration, you are staying for a process to complete or a file upload.

Find Elements

you’ll need the locators from it if you want to perform any automated action on a web page. These are unique identifiers associated with the web elements such as text, buttons, tables, div, etc.
It is not possible to interact with the web page if the test script is not able to find the web elements. Selenium Webdriver provides the following ways for detecting web elements.

  • Detect Element by Name
  • Detect Element by ID
  • Detect Element by Link Text
  • Detect Element by Partial Link Text
  • Detect Element by XPath
  • Detect Element by CSS Selector
  • Detect Element by Tag name
  • Detect Element by Class name

Click On Web Elements

We can click a button( elements) with Selenium web driver in Python using the click method ( .click() ). First, we have to identify the button to be clicked with the help of any locators like id, name, class, xpath, tagname, or CSS as per mention as per mentioned above. Then we have to apply the click method ( .click() ) on it. A button in HTML code is represented by a button tagname.

Sendkeys in Selenium

send_keys() is a method in Selenium that allows the Tester to type content automatically into an editable field while performing any tests for forms. For example, to test a login page, the username and password fields require some data to be entered. The tester uses the send_keys() method to enter the field values.

Submitting a form in Selenium

There are many techniques for submitting a form in Selenium. One of the methods is to directly use the click() method on the form submitting button. The next method is to use the submit() method on the form page.

In the below e.g you can get an idea that how to do automation testing in selenium with the python commands
URL="https://al3viewer.winsurtech.com/"
WEB_DRIVER_PATH="./chromedriver"
def invalidLogin():
driver = webdriver.Chrome(WEB_DRIVER_PATH)
driver.get(URL)
driver.find_element(By.LINK_TEXT, "SignIn").send_keys(Keys.ENTER)
time.sleep(5)
driver.find_element(By.ID, "id_remember").click()
username = driver.find_element(By.ID, "id_login")
username.click()
username.send_keys("YourUsername")
password = driver.find_element(By.ID, "id_password")
password.click()
password.send_keys("Pa55worD")
loginForm = driver.find_element(By.ID, "signin_form")
loginForm.submit()
time.sleep(5)
return True
invalidLogin = invalidLogin()

StudySection provides a big list of certification exams through its online platform. The French Certification Exam can help you to certify your skills to communicate in the French language. Whether you are new to the language or you are an expert in it, this French certification exam can test the ability of anybody’s command the French language.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri