Skip to content

Commit

Permalink
Merge pull request #87 from seleniumbase/update-selenium-ide-converter
Browse files Browse the repository at this point in the history
Update selenium ide converter
  • Loading branch information
mdmintz authored Apr 12, 2017
2 parents 49cee5c + e4bb092 commit 39facbe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
38 changes: 28 additions & 10 deletions integrations/selenium_ide/convert_ide.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,28 @@ def main():
continue

# Handle page loads
data = re.findall(
'^\s*driver\.get\(self\.base_url \+ \"/\"\)\s*$', line)
data = re.match(
'^(\s*)driver\.get\((self\.base_url \+ \"/\S*\")\)\s*$', line)
if data:
data = data[0].replace("self.base_url", '"%s"' % ide_base_url)
if ' + "/"' in data:
data = data.replace(' + "/"', '')
data = data.replace('driver.get(', 'self.open(')
seleniumbase_lines.append(data)
whitespace = data.group(1)
url = data.group(2)
url = url.replace("self.base_url", '"%s"' % ide_base_url)
if '/" + "/' in url:
url = url.replace('/" + "/', '/')
if "/' + '/" in url:
url = url.replace("/' + '/", "/")
command = '''%sself.open(%s)''' % (whitespace, url)
seleniumbase_lines.append(command)
continue

# Handle more page loads
data = re.match(
'^(\s*)driver\.get\(\"(\S*)\"\)\s*$', line)
if data:
whitespace = data.group(1)
url = data.group(2)
command = '''%sself.open('%s')''' % (whitespace, url)
seleniumbase_lines.append(command)
continue

# Handle .find_element_by_id() + .click()
Expand Down Expand Up @@ -220,11 +234,13 @@ def main():
seleniumbase_lines.append(command)
continue

# Replace "self.base_url" with actual url if not already done
if 'self.base_url' in line:
line = line.replace("self.base_url", '"%s"' % ide_base_url)

# Convert driver. to self.driver. if not already done
if 'driver.' in line and 'self.driver' not in line:
command = line.replace('driver.', 'self.driver.')
seleniumbase_lines.append(command)
continue
line = line.replace('driver.', 'self.driver.')

# Add all other lines to final script without making changes
seleniumbase_lines.append(line)
Expand All @@ -243,6 +259,8 @@ def main():
out_file = codecs.open(converted_file_name, "w+")
out_file.writelines(seleniumbase_code)
out_file.close()
print("%s successfully created from %s\n" % (
converted_file_name, webdriver_python_file))


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion server_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='seleniumbase',
version='1.3.9',
version='1.3.10',
description='Test Automation Framework - seleniumbase.com',
long_description='Automation Framework for Simple & Reliable Web Testing',
platforms='Mac * Windows * Linux * Docker',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='seleniumbase',
version='1.3.9',
version='1.3.10',
description='Test Automation Framework - seleniumbase.com',
long_description='Automation Framework for Simple & Reliable Web Testing',
platforms='Mac * Windows * Linux * Docker',
Expand Down

0 comments on commit 39facbe

Please sign in to comment.