-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesty_selenium_OLX.py
More file actions
219 lines (187 loc) · 9.21 KB
/
Testy_selenium_OLX.py
File metadata and controls
219 lines (187 loc) · 9.21 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import time
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
class TestLogowanie():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_logowanie0(self):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
ico_log = self.driver.find_element_by_xpath('//*[@id="topLoginLink"]')
ico_log.click()
time.sleep(2)
assert self.driver.find_element_by_xpath("/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[1]/div[1]/label").text \
== "E-mail (do konta OLX)"
assert self.driver.find_element_by_xpath(
"/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[2]/div[1]/label").text \
== "Hasło"
loguj_button = self.driver.find_element_by_xpath('//*[@id="se_userLogin"]')
loguj_button.click()
time.sleep(2)
# login
assert self.driver.find_element_by_xpath('/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[1]/div[2]/p/small/div/label').text \
== 'To pole jest wymagane'
# hasło
assert self.driver.find_element_by_xpath(
'/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[2]/div[2]/p/small/div/label').text \
== 'To pole jest wymagane'
def test_logowanie1(self):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
ico_log = self.driver.find_element_by_xpath('//*[@id="topLoginLink"]')
ico_log.click()
time.sleep(2)
assert self.driver.find_element_by_xpath(
"/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[1]/div[1]/label").text \
== "E-mail (do konta OLX)"
assert self.driver.find_element_by_xpath(
"/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[2]/div[1]/label").text \
== "Hasło"
log = self.driver.find_element_by_xpath('//*[@id="userEmail"]')
log.send_keys("login")
passw = self.driver.find_element_by_xpath('//*[@id="userPass"]')
passw.send_keys('passw')
loguj_button = self.driver.find_element_by_xpath('//*[@id="se_userLogin"]')
loguj_button.click()
assert self.driver.find_element_by_xpath('/html/body/div[3]/header/div[2]/div/div/div[1]/div[1]/h2').text \
== 'Twoje ogłoszenia'
class TestOferta():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_oferta0(self):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
time.sleep(1)
nowa = self.driver.find_element_by_xpath('//*[@id="postNewAdLink"]')
nowa.click()
time.sleep(2)
assert self.driver.find_element_by_xpath(
"/html/body/div[3]/section/div[3]/div/ul/li[1]/div/form/fieldset/div[1]/div[1]/label").text \
== "E-mail (do konta OLX)"
def test_oferta1(self):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
time.sleep(1)
#logowanie
ico_log = self.driver.find_element_by_xpath('//*[@id="topLoginLink"]')
ico_log.click()
time.sleep(2)
log = self.driver.find_element_by_xpath('//*[@id="userEmail"]')
log.send_keys('login')
passw = self.driver.find_element_by_xpath('//*[@id="userPass"]')
passw.send_keys('passw')
loguj_button = self.driver.find_element_by_xpath('//*[@id="se_userLogin"]')
loguj_button.click()
self.driver.find_element_by_xpath('//*[@id="headerLogo"]').click()
time.sleep(2)
nowa = self.driver.find_element_by_xpath('//*[@id="postNewAdLink"]')
nowa.click()
time.sleep(2)
assert self.driver.find_element_by_xpath('/html/body/div[3]/section/div/div/form/h1').text \
== 'Zaczynamy!'
class TestKategorie():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_model_auta(self):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
time.sleep(1)
self.driver.find_element(By.CSS_SELECTOR, ".cat-icon-5").click()
time.sleep(1)
self.driver.find_element(By.CSS_SELECTOR,
"#bottom5 > ul:nth-child(2) > li:nth-child(1) > a:nth-child(1)").click()
time.sleep(2)
model = self.driver.find_element_by_xpath(
"/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[1]/ul/li[1]/div[2]/a")
model.click()
time.sleep(2)
self.driver.find_element_by_xpath(
"/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[1]/ul/li[1]/div[2]/ul/li[3]/a").click()
time.sleep(1)
assert self.driver.find_element_by_xpath(
'/html/body/div[3]/div[5]/section/div[1]/div[1]/div[1]/ul/li[4]/h1').text == 'Używane Alfa Romeo sprzedam - OLX.pl'
def test_model_moto(self):
self.driver.get("https://www.olx.pl/")
time.sleep(1)
self.driver.find_element(By.CSS_SELECTOR, ".cat-icon-5").click()
time.sleep(1)
self.driver.find_element(By.CSS_SELECTOR,
"#bottom5 > ul:nth-child(2) > li:nth-child(2) > a:nth-child(1)").click()
time.sleep(2)
model = self.driver.find_element_by_xpath(
"/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[1]/ul/li[2]/div[2]/a")
model.click()
time.sleep(3)
self.driver.find_element_by_xpath(
"/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[1]/ul/li[2]/div[2]/ul/li[44]/label[2]").click()
time.sleep(2)
assert self.driver.find_element_by_xpath(
'/html/body/div[3]/div[5]/section/div[1]/div[1]/div[1]/ul/li[3]/h1').text \
== 'Używane motocykle i skutery sprzedam - OLX.pl'
class TestFiltrowanie():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_filtr_polska(self):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
time.sleep(1)
motoryzacja = self.driver.find_element_by_xpath( "/html/body/div[3]/section[1]/div[1]/div/div[1]/div[1]/div/a/span[2]")
motoryzacja.click()
time.sleep(1)
samochod = self.driver.find_element_by_xpath("/html/body/div[3]/section[1]/div[1]/div/div[2]/ul/li[1]/a")
samochod.click()
time.sleep(2)
#filtry
kraj_poch = self.driver.find_element_by_xpath('/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[9]/ul/li[2]/div[2]/a')
kraj_poch.click()
time.sleep(1)
self.driver.find_element_by_xpath(
'/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[9]/ul/li[2]/div[2]/ul/li[2]/label[2]').click()
assert self.driver.find_element_by_xpath(
'/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[9]/ul/li[2]/div[2]/a/span[1]').text == "Polska"
def test_filtr_cena(self, ):
self.driver.get("https://www.olx.pl/")
self.driver.set_window_size(1552, 840)
time.sleep(1)
motoryzacja = self.driver.find_element_by_xpath(
"/html/body/div[3]/section[1]/div[1]/div/div[1]/div[1]/div/a/span[2]")
motoryzacja.click()
time.sleep(1)
samochod = self.driver.find_element_by_xpath("/html/body/div[3]/section[1]/div[1]/div/div[2]/ul/li[1]/a")
samochod.click()
time.sleep(2)
cena_min = self.driver.find_element_by_xpath(
'/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[2]/ul/li/div[2]/div[1]/a/span[1]')
cena_min.click()
self.driver.find_element_by_css_selector('ul.binded:nth-child(3) > li:nth-child(4) > a:nth-child(1)').click()
time.sleep(1)
cena_max = self.driver.find_element_by_xpath(
'/html/body/div[3]/header/div[2]/div/form/noindex/div/fieldset[2]/ul/li[2]/ul/li/div[2]/div[2]/a/span[1]')
cena_max.click()
self.driver.find_element_by_css_selector('ul.binded:nth-child(3) > li:nth-child(10) > a:nth-child(1)').click()
time.sleep(1)
sort = self.driver.find_element_by_xpath('/html/body/div[3]/div[5]/div[1]/div/div[1]/form/dl/dt/a')
sort.click()
self.driver.find_element_by_xpath('/html/body/div[3]/div[5]/div[1]/div/div[1]/form/dl/dd/ul/li[3]/a').click()
time.sleep(2)
cena_samoch = self.driver.find_element_by_xpath(
'/html/body/div[3]/div[5]/section/div[3]/div/div[1]/table[1]/tbody/tr[3]/td/div/table/tbody/tr[1]/td[3]/div/p/strong').text
cena_samoch = cena_samoch[0:2]
assert int(cena_samoch) >32
if __name__ == '__main__':
pytest.main()