Skip to content

Commit c4d6957

Browse files
basic first cut pom
1 parent ef55f4d commit c4d6957

File tree

11 files changed

+81
-15
lines changed

11 files changed

+81
-15
lines changed

.coverage

0 Bytes
Binary file not shown.

Library/driver.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from selenium import webdriver
22
from selenium.webdriver.chrome.webdriver import WebDriver
3+
from selenium.webdriver.common.by import By
4+
from selenium.webdriver.remote import webelement
5+
from Library.store import Store
36

47
class Driver:
58
driver = None
@@ -11,11 +14,12 @@ def __init__(self,browser = "chrome") -> None:
1114
self.driver = webdriver.Firefox()
1215
elif browser == "safari":
1316
self.driver = webdriver.Safari()
14-
15-
def get_driver(self) -> WebDriver:
16-
return self.driver
17+
Store.push(self.driver)
1718

1819
def get(self, url: str) -> None:
1920
self.driver.get(url)
2021

22+
def find_element(self, by, value) -> webelement.WebElement:
23+
return self.driver.find_element(by, value)
24+
2125

Library/locator.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from Library.store import Store
2+
3+
4+
class Locator(Store):
5+
6+
def __init__(self, by: str, value: str) -> None:
7+
self.by = by
8+
self.value = value
9+
10+
def send_keys(self, string) -> None:
11+
Store.current_driver.find_element(self.by, self.value).send_keys(string)

Library/store.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.chrome.webdriver import WebDriver
3+
4+
class Store:
5+
drivers = []
6+
current_driver = None
7+
8+
def __init__(self):
9+
print("Storing the driver values")
10+
11+
@classmethod
12+
def push(self, driver: webdriver) -> webdriver:
13+
self.drivers.append(driver)
14+
self.set_current_driver(driver)
15+
16+
@classmethod
17+
def set_current_driver(self, driver: webdriver) -> webdriver:
18+
self.current_driver = driver
19+
20+
@classmethod
21+
def switch_driver(self, driver) -> webdriver:
22+
self.current_driver = driver

Locators/__init__.py

Whitespace-only changes.

Locators/google.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from selenium.webdriver.common.by import By
2+
from Library.locator import Locator
3+
4+
5+
class GoogleLocator:
6+
search_box = Locator("css selector", "input.gLFyf")
7+
8+
def __init__(self):
9+
print("Locators for google page")

Pages/__init__.py

Whitespace-only changes.

Pages/google.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from Locators.google import GoogleLocator
2+
3+
4+
class GooglePage(GoogleLocator):
5+
6+
def __init__(self):
7+
super
8+
9+
@classmethod
10+
def enter_search_text(cls, string):
11+
GoogleLocator.search_box.send_keys(string)
12+

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
# brew install python3
1+
# Install Python 3
2+
brew install python3
23

3-
# brew postinstall python3 #pip3 installation
4+
# Post installation on python 3 to get pip 3
5+
brew postinstall python3
6+
7+
# Install all the requirement packages by
8+
pip3 install -r requirements.txt
9+
10+
# Run the tests by
11+
```
12+
pytest
13+
```
414

5-
# pip3 install -r requirements.txt
615

Tests/google.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import pytest
22
from Library.driver import Driver
3+
from Library.locator import Locator
4+
from Pages.google import GooglePage
5+
36

47
def test_file1_method1():
5-
d = Driver("chrome")
6-
d.get("https://www.google.com")
7-
dr = d.get_driver()
8-
print(dr)
9-
x=5
10-
y=6
11-
assert x+1 == y,"test failed"
12-
# assert x == y,"test failed"
8+
d = Driver("chrome")
9+
d.get("https://www.google.com")
10+
GooglePage.enter_search_text("hello")

0 commit comments

Comments
 (0)