Skip to content

Console scripts update #176

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

Merged
merged 3 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 23 additions & 5 deletions console_scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Examples:
seleniumbase mkdir [DIRECTORY_NAME]
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE].py
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]
seleniumbase grid-hub start
seleniumbase grid-node start --hub=127.0.0.1
"""
Expand All @@ -20,7 +20,8 @@

def show_usage():
show_basic_usage()
print('Type "seleniumbase help" for more details.\n')
print('Type "seleniumbase help" for details on all commands. OR,')
print('Type "seleniumbase help [COMMAND]" for specific command info.\n')


def show_basic_usage():
Expand All @@ -31,8 +32,8 @@ def show_basic_usage():
print("")
print("Commands:")
print("")
print(" mkdir [DIRECTORY]")
print(" convert [FILENAME]")
print(" mkdir [NEW_TEST_DIRECTORY_NAME]")
print(" convert [PYTHON_WEBDRIVER_UNITTEST_FILE]")
print(" grid-hub {start|stop|restart} [OPTIONS]")
print(" grid-node {start|stop|restart} --hub=[HUB_IP] [OPTIONS]")
print("")
Expand All @@ -56,7 +57,7 @@ def show_convert_usage():
print(" ** convert **")
print("")
print(" Usage:")
print(" seleniumbase convert [MY_TEST.py]")
print(" seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]")
print(" Output:")
print(" Converts a Selenium IDE exported WebDriver unittest")
print(" file into a SeleniumBase file. Adds _SB to the new")
Expand Down Expand Up @@ -147,6 +148,23 @@ def main():
show_basic_usage()
show_grid_node_usage()
elif command == "help" or command == "--help":
if len(command_args) >= 1:
if command_args[0] == "mkdir":
print("")
show_mkdir_usage()
return
elif command_args[0] == "convert":
print("")
show_convert_usage()
return
elif command_args[0] == "grid-hub":
print("")
show_grid_hub_usage()
return
elif command_args[0] == "grid-node":
print("")
show_grid_node_usage()
return
show_detailed_help()
else:
show_usage()
Expand Down
22 changes: 15 additions & 7 deletions integrations/selenium_ide/convert_ide.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
Works with Katalon Recorder scripts: http://www.katalon.com/automation-recorder

Usage:
seleniumbase convert [MY_TEST.py]
seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE].py
(run from anywhere)
OR
python convert_ide.py [MY_TEST.py] (from the "selenium_ide/"" folder)
python convert_ide.py [PYTHON_WEBDRIVER_UNITTEST_FILE].py
(when run from the "selenium_ide/" folder)
Output:
[MY_TEST_SB.py] (Adds "_SB" to the file name)
[NEW_FILE_SB].py (adds "_SB" to the original file name)
(the original file is kept intact)
"""

import codecs
Expand All @@ -18,7 +21,7 @@

def main():
expected_arg = ("[A Katalon/Selenium IDE recording exported as "
"a Python-WebDriver script].py")
"a Python-WebDriver unittest script].py")
num_args = len(sys.argv)
if sys.argv[0].split('/')[-1] == "seleniumbase" or (
sys.argv[0].split('\\')[-1] == "seleniumbase"):
Expand All @@ -29,9 +32,11 @@ def main():
if num_args < 2 or num_args > 2:
raise Exception('\n* INVALID RUN COMMAND! * Usage:\n'
'"python convert_ide.py %s"\n' % expected_arg)
if not sys.argv[num_args-1].endswith('.py'):
raise Exception("Not a Python file!")
webdriver_python_file = sys.argv[num_args-1]
if not webdriver_python_file.endswith('.py'):
raise Exception("* `%s` is not a Python file! *\n"
"Expecting: %s\n"
% (webdriver_python_file, expected_arg))

seleniumbase_lines = []
seleniumbase_lines.append("from seleniumbase import BaseCase")
Expand All @@ -47,7 +52,10 @@ def main():
all_code = f.read()
f.close()
if "def test_" not in all_code:
raise Exception("Not a valid Python unittest.TestCase file!")
raise Exception("* `%s` is not a valid Python unittest.TestCase file! "
"*\nExpecting: %s\n"
"Did you properly export your Selenium-IDE recording "
"as a Python WebDriver unittest file?" % expected_arg)
code_lines = all_code.split('\n')
for line in code_lines:

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nose==1.3.7
pytest==3.6.3
pytest-html==1.19.0
pytest-xdist==1.22.2
six==1.10.0
six==1.11.0
flake8==3.5.0
requests==2.19.1
beautifulsoup4==4.6.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='seleniumbase',
version='1.12.1',
version='1.12.2',
description='Web Automation & Testing Framework - http://seleniumbase.com',
long_description='Web Automation and Testing Framework - seleniumbase.com',
platforms='Mac * Windows * Linux * Docker',
Expand All @@ -25,7 +25,7 @@
'pytest==3.6.3',
'pytest-html==1.19.0',
'pytest-xdist==1.22.2',
'six==1.10.0',
'six==1.11.0',
'flake8==3.5.0',
'requests==2.19.1',
'beautifulsoup4==4.6.0',
Expand Down