Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing async syntax for python 3.7 #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/pytractor/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ def __init__(self, base_url='', root_element='body', script_timeout=10,
self.set_script_timeout(script_timeout)

def _execute_client_script(self, script_name, *args, **kwargs):
async = kwargs.pop('async', True)
is_async = kwargs.pop('is_async', True)
file_name = '{}.js'.format(script_name)
js_script = resource_string(__name__,
'{}/{}'.format(CLIENT_SCRIPTS_DIR,
file_name))
if js_script:
js_script = js_script.decode('UTF-8')
if async:
if is_async:
result = self.execute_async_script(js_script, *args)
else:
result = self.execute_script(js_script, *args)
Expand All @@ -94,7 +94,7 @@ def wait_for_angular(self):
else:
return self._execute_client_script('waitForAngular',
self._root_element,
async=True)
is_async=True)

def execute(self, driver_command, params=None):
# We also get called from WebElement methods/properties.
Expand Down Expand Up @@ -131,13 +131,13 @@ def title(self):
@angular_wait_required
def location_abs_url(self):
return self._execute_client_script('getLocationAbsUrl',
self._root_element, async=False)
self._root_element, is_async=False)

@angular_wait_required
def find_elements_by_repeater(self, descriptor, using=None):
return self._execute_client_script('findAllRepeaterRows',
descriptor, False, using,
async=False)
is_async=False)

@angular_wait_required
def find_element(self, *args, **kwargs):
Expand All @@ -150,7 +150,7 @@ def find_elements(self, *args, **kwargs):
@angular_wait_required
def find_elements_by_binding(self, descriptor, using=None):
elements = self._execute_client_script('findBindings', descriptor,
False, using, async=False)
False, using, is_async=False)
return elements

def find_element_by_binding(self, descriptor, using=None):
Expand All @@ -176,7 +176,7 @@ def find_element_by_exact_binding(self, descriptor, using=None):
@angular_wait_required
def find_elements_by_exact_binding(self, descriptor, using=None):
elements = self._execute_client_script('findBindings', descriptor,
True, using, async=False)
True, using, is_async=False)
return elements

def find_element_by_model(self, descriptor, using=None):
Expand All @@ -192,7 +192,7 @@ def find_element_by_model(self, descriptor, using=None):
@angular_wait_required
def find_elements_by_model(self, descriptor, using=None):
elements = self._execute_client_script('findByModel', descriptor,
using, async=False)
using, is_async=False)
# Workaround for issue #10: findByModel.js returns None instead of empty
# list if no element has been found.
if elements is None:
Expand Down Expand Up @@ -233,5 +233,5 @@ def refresh(self):
@angular_wait_required
def set_location(self, url):
result = self._execute_client_script('setLocation', self._root_element,
url, async=False)
url, is_async=False)
return result