Update console scripts (Add more files with "sbase mkdir DIR")

This commit is contained in:
Michael Mintz 2021-03-19 00:07:31 -04:00
parent 122ea92953
commit 78452e2f0f
1 changed files with 52 additions and 4 deletions

View File

@ -492,24 +492,46 @@ def main():
data.append("class DataPage():") data.append("class DataPage():")
data.append("") data.append("")
data.append(" def go_to_data_url(self, sb):") data.append(" def go_to_data_url(self, sb):")
data.append(" sb.open(\"data:text/html,<p>Hello!</p><input />\")") data.append(' sb.open("data:text/html,<p>Hello!</p><input />")')
data.append("") data.append("")
data.append(" def add_input_text(self, sb, text):") data.append(" def add_input_text(self, sb, text):")
data.append(" sb.type(\"input\", text)") data.append(' sb.type("input", text)')
data.append("") data.append("")
data.append("") data.append("")
data.append("class ObjTests(BaseCase):") data.append("class ObjTests(BaseCase):")
data.append("") data.append("")
data.append(" def test_data_url_page(self):") data.append(" def test_data_url_page(self):")
data.append(" DataPage().go_to_data_url(self)") data.append(" DataPage().go_to_data_url(self)")
data.append(" self.assert_text(\"Hello!\", \"p\")") data.append(' self.assert_text("Hello!", "p")')
data.append(" DataPage().add_input_text(self, \"Goodbye!\")") data.append(' DataPage().add_input_text(self, "Goodbye!")')
data.append("") data.append("")
file_path = "%s/%s" % (dir_name_2, "classic_obj_test.py") file_path = "%s/%s" % (dir_name_2, "classic_obj_test.py")
file = codecs.open(file_path, "w+", "utf-8") file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data)) file.writelines("\r\n".join(data))
file.close() file.close()
data = []
data.append("class DataPage():")
data.append("")
data.append(" def go_to_data_url(self, sb):")
data.append(' sb.open("data:text/html,<p>Hello!</p><input />")')
data.append("")
data.append(" def add_input_text(self, sb, text):")
data.append(' sb.type("input", text)')
data.append("")
data.append("")
data.append("class ObjTests():")
data.append("")
data.append(" def test_data_url_page(self, sb):")
data.append(" DataPage().go_to_data_url(sb)")
data.append(' sb.assert_text("Hello!", "p")')
data.append(' DataPage().add_input_text(sb, "Goodbye!")')
data.append("")
file_path = "%s/%s" % (dir_name_2, "sb_fixture_test.py")
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()
dir_name_3 = dir_name_2 + "/" + "samples" dir_name_3 = dir_name_2 + "/" + "samples"
os.mkdir(dir_name_3) os.mkdir(dir_name_3)
@ -566,6 +588,32 @@ def main():
file.writelines("\r\n".join(data)) file.writelines("\r\n".join(data))
file.close() file.close()
data = []
data.append("from seleniumbase import BaseCase")
data.append("")
data.append("")
data.append("class LoginPage():")
data.append("")
data.append(" def login_to_swag_labs(self, sb, username):")
data.append(' sb.type("#user-name", username)')
data.append(' sb.type("#password", "secret_sauce")')
data.append(" sb.click('input[type=\"submit\"]')")
data.append("")
data.append("")
data.append("class MyTests(BaseCase):")
data.append("")
data.append(" def test_swag_labs_login(self):")
data.append(' self.open("https://www.saucedemo.com/")')
data.append(
' LoginPage().login_to_swag_labs(self, "standard_user")')
data.append(' self.assert_element("#inventory_container")')
data.append(' self.assert_text("Products", "div.product_label")')
data.append("")
file_path = "%s/%s" % (dir_name_3, "swag_labs_test.py")
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()
success = ( success = (
'\n' + c1 + '* Directory "' + dir_name + '" was created ' '\n' + c1 + '* Directory "' + dir_name + '" was created '
'with config files and sample tests! *' + cr + '\n') 'with config files and sample tests! *' + cr + '\n')