Skip to content

Commit 794ad3d

Browse files
committed
Fixing conftest file to operate correct.
1 parent 347491f commit 794ad3d

File tree

4 files changed

+85
-51
lines changed

4 files changed

+85
-51
lines changed

Pytest_Framework/conftest.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import pytest
22
from selenium import webdriver
33

4-
# Firefox webdriver
5-
fDriver = webdriver.Firefox()
4+
@pytest.fixture(scope="class") # Χρησιμοποιούμε το scope "class" για να χρησιμοποιείται εντός class
5+
def setup(request): # Εδώ διαχειριζόμαστε το driver
6+
print('Start Setup')
7+
driver = webdriver.Firefox()
8+
driver.get('https://www.ggeorgiou.gr/')
69

10+
# Μοιράζουμε τον driver στα tests
11+
request.cls.driver = driver
712

8-
@pytest.fixture()
9-
def setup():
10-
print('Start Setup')
11-
fDriver.get('https://www.ggeorgiou.gr/')
13+
yield driver
1214

13-
yield # commands executed after the main test
14-
print(' End Setup')
15+
print('End Setup')
16+
driver.quit()

Pytest_Framework/geckodriver.log

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ JavaScript error: , line 0: NotFoundError: No such JSProcessActor 'DevToolsProce
263263
JavaScript error: , line 0: NotFoundError: No such JSProcessActor 'DevToolsProcess'
264264
JavaScript error: , line 0: NotFoundError: No such JSProcessActor 'DevToolsProcess'
265265
JavaScript error: , line 0: NotFoundError: No such JSProcessActor 'DevToolsProcess'
266-
1732786962331 geckodriver INFO Listening on 127.0.0.1:51767
266+
JavaScript error: , line 0: NS_ERROR_NOT_AVAILABLE
267+
1:51767
267268
1732786965412 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "--remote-debugging-port" "51768" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "C:\\Users\\HP\\AppData\\Local\\Temp\\rust_mozprofileJt2VgO"
268269
console.warn: services.settings: Ignoring preference override of remote settings server
269270
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
@@ -360,3 +361,61 @@ Read port: 52044
360361
1732788044373 RemoteAgent WARN TLS certificate errors will be ignored for this session
361362
1732788064898 Marionette INFO Stopped listening on port 52044
362363
Dynamically enable window occlusion 1
364+
1732792775262 geckodriver INFO Listening on 127.0.0.1:61114
365+
1732792778335 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "--remote-debugging-port" "61115" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "C:\\Users\\HP\\AppData\\Local\\Temp\\rust_mozprofile599xhv"
366+
console.warn: services.settings: Ignoring preference override of remote settings server
367+
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
368+
Dynamically enable window occlusion 0
369+
1732792778781 Marionette INFO Marionette enabled
370+
1732792778916 Marionette INFO Listening on port 61123
371+
WebDriver BiDi listening on ws://127.0.0.1:61115
372+
Read port: 61123
373+
1732792779107 RemoteAgent WARN TLS certificate errors will be ignored for this session
374+
1732792793201 Marionette INFO Stopped listening on port 61123
375+
JavaScript warning: https://www.gstatic.com/recaptcha/releases/pPK749sccDmVW_9DSeTMVvh2/recaptcha__en.js, line 171: Script terminated by timeout at:
376+
p</N</Y.U.onmessage@https://www.gstatic.com/recaptcha/releases/pPK749sccDmVW_9DSeTMVvh2/recaptcha__en.js:171:131
377+
378+
Dynamically enable window occlusion 1
379+
1732792820272 geckodriver INFO Listening on 127.0.0.1:61158
380+
1732792823311 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "--marionette" "--remote-debugging-port" "61159" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "C:\\Users\\HP\\AppData\\Local\\Temp\\rust_mozprofilepoVuTy"
381+
console.warn: services.settings: Ignoring preference override of remote settings server
382+
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
383+
Dynamically enable window occlusion 0
384+
1732792823990 Marionette INFO Marionette enabled
385+
1732792824142 Marionette INFO Listening on port 61166
386+
WebDriver BiDi listening on ws://127.0.0.1:61159
387+
Read port: 61166
388+
1732792824364 RemoteAgent WARN TLS certificate errors will be ignored for this session
389+
JavaScript warning: https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG, line 184: Script terminated by timeout at:
390+
ib@https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG:184:159
391+
gB@https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG:594:135
392+
hB/<@https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG:594:111
393+
394+
1732793106981 Marionette INFO Stopped listening on port 61166
395+
Dynamically enable window occlusion 1
396+
services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
397+
Dynamically enable window occlusion 0
398+
1732792841008 Marionette INFO Marionette enabled
399+
1732792841144 Marionette INFO Listening on port 61199
400+
WebDriver BiDi listening on ws://127.0.0.1:61192
401+
Read port: 61199
402+
1732792841338 RemoteAgent WARN TLS certificate errors will be ignored for this session
403+
JavaScript warning: https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG, line 184: Script terminated by timeout at:
404+
ib@https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG:184:159
405+
gB@https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG:594:135
406+
hB/<@https://www.googletagmanager.com/gtag/js?id=G-E423JL13RG:594:111
407+
408+
1732793092503 Marionette INFO Stopped listening on port 61199
409+
Dynamically enable window occlusion 1
410+
services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
411+
Dynamically enable window occlusion 0
412+
1732793064865 Marionette INFO Marionette enabled
413+
1732793065080 Marionette INFO Listening on port 61259
414+
WebDriver BiDi listening on ws://127.0.0.1:61251
415+
Read port: 61259
416+
1732793065255 RemoteAgent WARN TLS certificate errors will be ignored for this session
417+
1732793079454 Marionette INFO Stopped listening on port 61259
418+
JavaScript warning: https://www.gstatic.com/recaptcha/releases/pPK749sccDmVW_9DSeTMVvh2/recaptcha__en.js, line 171: Script terminated by timeout at:
419+
p</N</Y.U.onmessage@https://www.gstatic.com/recaptcha/releases/pPK749sccDmVW_9DSeTMVvh2/recaptcha__en.js:171:131
420+
421+
Dynamically enable window occlusion 1
Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
"""
2-
Using fixtures in plain way
2+
Using fixtures in a plain way
33
"""
44
import pytest
5-
from selenium import webdriver
65
from selenium.webdriver.common.by import By
76

8-
fDriver = webdriver.Firefox()
7+
@pytest.mark.usefixtures("setup") # Ενημερώνουμε ότι το fixture θα χρησιμοποιηθεί από την κλάση
8+
class Test_GG_Site:
99

10-
"""
11-
@pytest.fixture()
12-
def setup():
13-
print('Start Setup')
14-
# Firefox webdriver
15-
fDriver.get('https://www.ggeorgiou.gr/')
16-
17-
yield # commands executed after the main test
18-
print(' End Setup')
19-
"""
20-
21-
22-
def test_search_term__wordpress(setup):
23-
fDriver.find_element(By.XPATH, "//input[@id='s']").send_keys('wordpress')
24-
fDriver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()
10+
def test_search_term__wordpress(self): # Το "setup" είναι το fixture
11+
self.driver.find_element(By.XPATH, "//input[@id='s']").send_keys('wordpress')
12+
self.driver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()
2513

2614

27-
def test_search_term__seo(setup):
28-
fDriver.find_element(By.XPATH, "//input[@id='s']").send_keys('seo')
29-
fDriver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()
15+
def test_search_term__seo(self):
16+
self.driver.find_element(By.XPATH, "//input[@id='s']").send_keys('seo')
17+
self.driver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()

Pytest_Framework/test_ggeorgiougr_site2.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,15 @@
22
Using fixtures by using class
33
"""
44
import pytest
5-
from selenium import webdriver
65
from selenium.webdriver.common.by import By
76

8-
fDriver = webdriver.Firefox()
9-
10-
"""
11-
@pytest.fixture()
12-
def setup():
13-
print('Start Setup')
14-
# Firefox webdriver
15-
fDriver.get('https://www.ggeorgiou.gr/')
16-
17-
yield # commands executed after the main test
18-
print(' End Setup')
19-
"""
20-
21-
22-
@pytest.mark.usefixtures("setup")
23-
class Test_GG_Site:
7+
@pytest.mark.usefixtures("setup") # Ενημερώνουμε ότι το fixture θα χρησιμοποιηθεί από την κλάση
8+
class Test_GG_Site2:
249

2510
def test_search_term__html(self):
26-
fDriver.find_element(By.XPATH, "//input[@id='s']").send_keys('html')
27-
fDriver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()
11+
self.driver.find_element(By.XPATH, "//input[@id='s']").send_keys('html')
12+
self.driver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()
2813

2914
def test_search_term__css(self):
30-
fDriver.find_element(By.XPATH, "//input[@id='s']").send_keys('css')
31-
fDriver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()
15+
self.driver.find_element(By.XPATH, "//input[@id='s']").send_keys('css')
16+
self.driver.find_element(By.XPATH, "//span[@class='ignition-icons ignition-icons-search']").click()

0 commit comments

Comments
 (0)