How to fill form automatically using selenium in Python

In this tutorial, we will learn how to fill form automatically using selenium in python with some cool and easy examples. In many situations, you might have to come up with this type of requirements.

I know you are here just because you are in need of this awesome trick to take only a single character as an input in Python ignoring all the characters entered by the user except the first character.

If you don’t know how to ignore all the characters of user input except the first character then you are at the right place. Because in this tutorial we gonna find out how to accept only first character as an user input in Python.

Fill form automatically using selenium in python

 

At first, create a variable which can hold webdriver.

from selenium import webdriver
from selenium.webdriver.commomn.by import By

Selenium WebDriver is a set of APIs that allows automatic interaction between your test automation code and the web browser on which automation tests are performed. Selenium allows the automation of browsers by sending commands to it, making it an exciting framework for automating user interface tests.

from selenium import webdriver
from selenium.webdriver.commomn.by import By

from selenium.webdriver.support.ui import Select

import time

 driver webdriver.Chrome("C:\Selenium_Development\chromedriver.exe")

 driver.get("https://selenium-practice.netlify.app/")



name_input = driver.find_element(By.XPATH, '//*[@id="name"]')

 name_input.send_keys("Roy")



selection_input = driver.find_element(By.XPATH, '//*[@id="selection"]')

 select = Select(selection_input)

 select.select_by_visible_text("Item 3")

 driver.find_element(By.XPATH, '//*[@id="check2"]').click()

driver.find_element(By.XPATH, '//*[@id="check3"]').click()


date_input driver.find_element(By.XPATH, '//*[@id="date"]')

date_input.click()

 date_input.send_keys("01012019")

time.sleep(2)

driver.quit()

output

https://selenium-practice.netlify.app/

 

Leave a Comment

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

Scroll to Top