def setUp_and_login(browser):
'''
Supported browsers are: firefox; chrome
'''
#
if browser == 'firefox':
driver = webdriver.Firefox()
elif browser == 'chrome':
driver = webdriver.Chrome('Location of Chromedriver utility')
else:
print('')
print('Browser not recognized, exiting...')
print('')
exit()
Monday, 24 August 2015
Sunday, 16 August 2015
Purpose of self in Python
from selenium import webdriver
#
Class MyClass:
def function(self):
self.driver = webdriver.Firefox()
What is the purpose of SELF here:
"
"
"
The
"
Source:
http://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self-in-python
#
Class MyClass:
def function(self):
self.driver = webdriver.Firefox()
What is the purpose of SELF here:
"
self
is an object reference to the object itself, therefore, they are same. Python methods are not called in the context of the object itself. self
in Python may be used to deal with custom object models or something."
"
The
self
variable refers to the object itself."
Source:
http://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self-in-python
Saturday, 15 August 2015
How to import your own module in Python
Follow the link below to see how to import your own module as a Python package.
http://stackoverflow.com/questions/9383014/cant-import-my-own-modules-in-python
http://stackoverflow.com/questions/9383014/cant-import-my-own-modules-in-python
Sunday, 9 August 2015
Python Modules - how to find location of module sources
Let's assume we want to find the source of Python module Selenium.
In Python Shell:
>>> import selenium
>>>
>>> selenium.__file__
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/__init__.pyc'
>>>
In Python Shell:
>>> import selenium
>>>
>>> selenium.__file__
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/__init__.pyc'
>>>
Subscribe to:
Posts (Atom)