-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomePage.py
More file actions
60 lines (47 loc) · 2.05 KB
/
HomePage.py
File metadata and controls
60 lines (47 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import random
import string
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
class BasePage(object):
def __init__(self, driver):
self.driver = driver
class HomePageObject(BasePage):
#Form locators
iam = ["femaleSoy", "maleSoy"]
looking = ["femaleBusco", "maleBusco"]
birthdayDay = 'birthDateDay'
birthdayMonth = 'birthDateMonth'
birthdayYear = 'birthDateYear'
region = 'provinceregion'
email = 'email'
user = 'userLogin'
password = 'password'
register = 'register'
loginButton = 'a.btn.btn-azul.btn--brand'
def add_interests(self):
sex = [random.randint(0,1), random.randint(0,1)]
iam = self.driver.find_element(By.XPATH, "//label[@for='" + self.iam[sex[0]] + "']").click()
looking = self.driver.find_element(By.XPATH, "//label[@for='" + self.looking[sex[1]] + "']").click()
def add_email(self, email):
self.driver.find_element_by_name(self.email).send_keys(email)
def add_birth_date(self):
birth_date = [random.randint(1,31),random.randint(1,12),random.randint(1937,1999)]
day = Select(self.driver.find_element_by_name(self.birthdayDay))
day.select_by_value(str(birth_date[0]))
month = Select(self.driver.find_element_by_name(self.birthdayMonth))
month.select_by_value(str(birth_date[1]).zfill(2))
year = Select(self.driver.find_element_by_name(self.birthdayYear))
year.select_by_value(str(birth_date[2]))
def add_region(self):
region = Select(self.driver.find_element_by_id(self.region))
region.select_by_value(str(random.randint(1,50)).zfill(2))
def add_username(self, len=10):
username = ''.join(random.sample(string.ascii_lowercase, len))
user = self.driver.find_element_by_name(self.user).send_keys(username)
return username
def add_password(self, len=10):
password = self.driver.find_element_by_name(self.password).send_keys(''.join(random.sample(string.ascii_lowercase, len)))
def click_register(self):
self.driver.find_element_by_name(self.register).click()
def click_already_user(self):
self.driver.find_element_by_css_selector(self.loginButton).click()