Skip to content

Commit 556a673

Browse files
adding quit browser function to close browser
1 parent e6c0ca2 commit 556a673

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ A simple selenium extension which contains Browser class with methods defining d
55

66
## Development purpose
77

8-
---
9-
108
- The goal of web tester is to reduce the code complexities for developing a testing script that should test if your web applications is working fine.
119
- When ever a developer or designer make a changes to your web application. Testing needs to be performed for all the elements of your web.
1210
- After every change you may need to add or modify a lengthy selenium code.
@@ -15,8 +13,6 @@ A simple selenium extension which contains Browser class with methods defining d
1513

1614
## Actions Available
1715

18-
---
19-
2016
- open_url
2117
- fetch_element
2218
- click_element
@@ -30,9 +26,11 @@ A simple selenium extension which contains Browser class with methods defining d
3026

3127
python setup.py install
3228

33-
## Example
29+
## Drivers
3430

35-
---
31+
For headless mode which can be used for automate the testing I prefer using [headless_ie_selenium](https://github.com/kybu/headless-selenium-for-win/releases) driver.
32+
33+
## Example
3634

3735
``` python
3836
# Example for IE
@@ -42,7 +40,10 @@ driver_location = "/path/to/IEdriver.exe" #or "/path/to/selenium_headless_ie.exe
4240

4341
browser = Browser(driver_location,"IE")
4442

45-
browser.open_url('https://github.com/vishnu-chegondi/')
46-
action = browser.click_element('//*[@id="js-pjax-container"]/div/div[2]/div[3]/div[1]/div/ol/li[3]/span/span/a',"Unable to navigate to project")
43+
browser.open_url('https://selenium-python.readthedocs.io/')
44+
action = browser.click_element('//*[@id="selenium-with-python"]/div[2]/ul/li[1]/a',"Unable to click on element")
45+
if action == "ActionPerformed":
46+
print ("Opened Docs for python selenium")
4747

48+
# browser.psuedo_browser.quit()
4849
```

examples/git_nav.py

Whitespace-only changes.

web_tester/browser.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,14 @@ def fetch_all_elements(self, xpath, error="Element not found"):
154154
elements = WebDriverWait(self.psuedo_browser, 10).until(EC.presence_of_all_elements_located((By.XPATH, xpath)))
155155
return elements
156156
except Exception as _:
157-
return error
157+
return error
158+
159+
def close_browser(self):
160+
'''
161+
Closes the browser
162+
'''
163+
try:
164+
self.psuedo_browser.quit()
165+
return "ActionPerformed"
166+
except Exception as e:
167+
return "Error in closing browser : {}".format(e)

0 commit comments

Comments
 (0)