Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skushwaha authored and skushwaha committed Aug 9, 2020
1 parent 95297dc commit 993b0ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions palladium/chrome_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@


class ChromeCustom(Chrome):
logs_dir = os.path.join('.', 'logs')

def __init__(self, headless=True, logs_dir=None):
def __init__(
self,
headless=True,
logs_dir=None,
log_error=False
):
self.logs_dir = os.path.join(os.getcwd() if logs_dir is None else logs_dir, 'logs')
self.log_error = log_error

chrome_options = ChromeOptions()

Expand Down Expand Up @@ -61,9 +66,10 @@ def attempt(
except Exception as exp:
time.sleep(wait_time)
if i + 1 == total_attempts:
logging.exception(exp)
name = ''.join([str(i) for i in [random.randint(0, 9) for j in range(12)]])
self.get_screenshot_as_file(os.path.join(self.logs_dir, f'screenshot_{name}.png'))
if self.log_error:
logging.exception(exp)
name = ''.join([str(i) for i in [random.randint(0, 9) for j in range(12)]])
self.get_screenshot_as_file(os.path.join(self.logs_dir, f'screenshot_{name}.png'))
raise Exception(f'Attempt failed for method. {method}')

def highlight(self, element, color='red', border=5, effect_time=5):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ six==1.15.0
tqdm==4.48.2
twine==3.2.0
urllib3==1.25.10
viper-python==0.1.1
viper-python==0.1.3
webencodings==0.5.1
zipp==3.1.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
setup(
name='palladium-python',
packages=['palladium'],
version='0.1.2',
version='0.1.3',
license='MIT',
description='Common utility functions.',
author='Siddhant Kushwaha',
author_email='[email protected]',
url='https://github.com/siddhantkushwaha/palladium',
download_url='https://github.com/siddhantkushwaha/palladium/archive/0.1.2.tar.gz',
download_url='https://github.com/siddhantkushwaha/palladium/archive/0.1.3.tar.gz',
keywords=['CHROMIUM', 'SELENIUM', 'AUTOMATION', 'TESTING'],
install_requires=[
'requests',
Expand Down

0 comments on commit 993b0ad

Please sign in to comment.