Previously, I had worked in selenium with java automation. I had learnt page object design pattern , core java , selenium webdriver concepts. then do automate the each page has each class file and automate each page, then keep the data in property file.
Now I want to do with selenium with Python automation. I learned python basics and selenium python concepts. I am new in this python automation. I don't how to get start. I learnt some basics. How to start get to do? I meant like easy methods, what should every python testers should following any framework, page object design pattern.
This is my registration page:
import unittest
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
class PythonRegister(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome(executable_path="/home/naveen/chromedriver")
self.driver.maximize_window()
def test_search_in_python_org(self):
driver = self.driver
driver.get("http://demoqa.com")
driver.find_element_by_link_text("Registration").click()
# time.sleep(10)
elem=driver.find_element_by_id("name_3_firstname")
elem.send_keys("Antony")
elem=driver.find_element_by_id("name_3_lastname")
elem.send_keys("Naveen")
elem=driver.find_element_by_css_selector("input[type='radio'][value='married']").click()
# time.sleep(5)
elem=driver.find_element_by_xpath("//*[@id='pie_register']/li[3]/div/div[1]/input[1]").click()
time.sleep(5)
select = Select(driver.find_element_by_id('dropdown_7'))
# select by visible text
select.select_by_visible_text('India')
# month od date
select = Select(driver.find_element_by_id('mm_date_8'))
select.select_by_visible_text('9')
# day of date
select = Select(driver.find_element_by_id('dd_date_8'))
select.select_by_visible_text('3')
#year of date
select = Select(driver.find_element_by_id('yy_date_8'))
select.select_by_visible_text('1993')
time.sleep(10)
elem=driver.find_element_by_id("phone_9")
elem.send_keys("9400693133")
elem=driver.find_element_by_id("email_1")
elem.send_keys("naveencjnv@gmail.com")
elem=driver.find_element_by_id("profile_pic_10")
elem.send_keys("/home/naveen/Documents/pp (1).jpg")
elem=driver.find_element_by_id("password_2")
elem.send_keys("antony111")
elem=driver.find_element_by_id("confirm_password_password_2")
elem.send_keys("antony111")
time.sleep(10)
elem=driver.find_element_by_xpath("//*[@id='pie_register']/li[14]/div/input").click()
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
What should I need to improve? What should I need to learn?