Commit f777a8f2 by linguangwei

增加了调试中的切换环境方法

parent ae86963a
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="review"> <list default="true" id="00f4febb-36b6-426d-bfe6-b023876a617e" name="Default Changelist" comment="添加本地文件路径区分mac/windows">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pageobject/mainpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/mainpage.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pageobject/basepage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/basepage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/test_MainPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_MainPage.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pageobject/loginpage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pageobject/loginpage.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/testcase/test_LoginPage.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/testcase/test_LoginPage.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -61,7 +62,9 @@ ...@@ -61,7 +62,9 @@
<option name="height" value="1321" /> <option name="height" value="1321" />
</component> </component>
<component name="ProjectId" id="1tNJXUBIdF7Iljvh6v3JNiXndy2" /> <component name="ProjectId" id="1tNJXUBIdF7Iljvh6v3JNiXndy2" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true">
<OptionsSetting value="false" id="Update" />
</component>
<component name="ProjectView"> <component name="ProjectView">
<navigator proportions="" version="1"> <navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
...@@ -159,8 +162,8 @@ ...@@ -159,8 +162,8 @@
<recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" /> <recent name="C:\Users\Administrator\PycharmProjects\xm-uitest-live" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.main"> <component name="RunManager" selected="Python tests.pytest for test_LoginPage.TestLoginPage.testLogin">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="demo" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -172,8 +175,7 @@ ...@@ -172,8 +175,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/demo.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -182,23 +184,29 @@ ...@@ -182,23 +184,29 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for test_MainPage.TestMainPage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/testcase" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_keywords" value="&quot;&quot;" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="PARAMETERS" value="" />
<option name="_new_target" value="&quot;test_MainPage.TestMainPage&quot;" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for test_MainPage.TestMainPage.test_2_StartLive" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="pytest for test_LoginPage.TestLoginPage" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -210,11 +218,11 @@ ...@@ -210,11 +218,11 @@
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_MainPage.TestMainPage.test_2_StartLive&quot;" /> <option name="_new_target" value="&quot;test_LoginPage.TestLoginPage&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for test_MainPage.TestMainPage.test_3_ReviewLive" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="pytest for test_LoginPage.TestLoginPage.testLogin" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -226,11 +234,11 @@ ...@@ -226,11 +234,11 @@
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_MainPage.TestMainPage.test_3_ReviewLive&quot;" /> <option name="_new_target" value="&quot;test_LoginPage.TestLoginPage.testLogin&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoard" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true"> <configuration name="pytest for test_MainPage.TestMainPage.test_2_StartLive" type="tests" factoryName="py.test" temporary="true" nameIsGenerated="true">
<module name="xm-uitest-live" /> <module name="xm-uitest-live" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -242,17 +250,17 @@ ...@@ -242,17 +250,17 @@
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_WhiteBoardPage.TestLivePage.testWhiteBoard&quot;" /> <option name="_new_target" value="&quot;test_MainPage.TestMainPage.test_2_StartLive&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" /> <option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python tests.pytest for test_LoginPage.TestLoginPage.testLogin" />
<item itemvalue="Python tests.pytest for test_LoginPage.TestLoginPage" />
<item itemvalue="Python.demo" />
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python tests.pytest for test_MainPage.TestMainPage.test_2_StartLive" /> <item itemvalue="Python tests.pytest for test_MainPage.TestMainPage.test_2_StartLive" />
<item itemvalue="Python tests.pytest for test_MainPage.TestMainPage" />
<item itemvalue="Python tests.pytest for test_MainPage.TestMainPage.test_3_ReviewLive" />
<item itemvalue="Python tests.pytest for test_WhiteBoardPage.TestLivePage.testWhiteBoard" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
...@@ -401,7 +409,49 @@ ...@@ -401,7 +409,49 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1624433942468</updated> <updated>1624433942468</updated>
</task> </task>
<option name="localTasksCounter" value="19" /> <task id="LOCAL-00019" summary="mainpage拆分为多个allure.step步骤">
<created>1624448489590</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1624448489590</updated>
</task>
<task id="LOCAL-00020" summary="操作被隐藏的元素界面可视">
<created>1625561212467</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1625561212467</updated>
</task>
<task id="LOCAL-00021" summary="操作被隐藏的元素界面可视-2,公共方法login添加">
<created>1625561298275</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1625561298275</updated>
</task>
<task id="LOCAL-00022" summary="判断当前系统是否为Windows或者darwin(mac)(当前只有两钟系统)">
<created>1625561787863</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1625561787863</updated>
</task>
<task id="LOCAL-00023" summary="review">
<created>1625561912397</created>
<option name="number" value="00023" />
<option name="presentableId" value="LOCAL-00023" />
<option name="project" value="LOCAL" />
<updated>1625561912397</updated>
</task>
<task id="LOCAL-00024" summary="添加本地文件路径区分mac/windows">
<created>1625562469198</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1625562469198</updated>
</task>
<option name="localTasksCounter" value="25" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
...@@ -510,8 +560,13 @@ ...@@ -510,8 +560,13 @@
<MESSAGE value="添加测试白板的page和testcase" /> <MESSAGE value="添加测试白板的page和testcase" />
<MESSAGE value="修改为pytest框架" /> <MESSAGE value="修改为pytest框架" />
<MESSAGE value="allure添加截图" /> <MESSAGE value="allure添加截图" />
<MESSAGE value="mainpage拆分为多个allure.step步骤" />
<MESSAGE value="操作被隐藏的元素界面可视" />
<MESSAGE value="操作被隐藏的元素界面可视-2,公共方法login添加" />
<MESSAGE value="判断当前系统是否为Windows或者darwin(mac)(当前只有两钟系统)" />
<MESSAGE value="review" /> <MESSAGE value="review" />
<option name="LAST_COMMIT_MESSAGE" value="review" /> <MESSAGE value="添加本地文件路径区分mac/windows" />
<option name="LAST_COMMIT_MESSAGE" value="添加本地文件路径区分mac/windows" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/server.log" /> <entry file="file://$PROJECT_DIR$/server.log" />
......
...@@ -5,7 +5,7 @@ from src.framework import common ...@@ -5,7 +5,7 @@ from src.framework import common
if __name__ == '__main__': if __name__ == '__main__':
htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute()) htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
pytest.main(["-v", '--alluredir={}'.format(htmlPath), './src/testcase/test_MainPage.py', "--durations=0"]) pytest.main(["-v", '--alluredir={}'.format(htmlPath), './src/testcase/test_WhiteBoardPage.py', "--durations=0"])
os.system('allure generate {} -o ./report/output --clean'.format(htmlPath)) os.system('allure generate {} -o ./report/output --clean'.format(htmlPath))
# # 定义报告输出路径 # # 定义报告输出路径
......
...@@ -74,8 +74,12 @@ class Page(object): ...@@ -74,8 +74,12 @@ class Page(object):
return sleep(seconds) return sleep(seconds)
# 查找文本,点击该文本元素 # 查找文本,点击该文本元素
def click_text(self, text): def click_text(self, ele):
self.click((By.XPATH, """//span[text()="{}"]""".format(text))) self.click((By.XPATH, """//span[text()="{}"]""".format(ele)))
def click_what(self, ele_type, what, ele):
self.click((By.XPATH, """//{}[{}="{}"]""".format(ele_type, what, ele)))
# 键盘down # 键盘down
def keys_down(self): def keys_down(self):
...@@ -84,11 +88,12 @@ class Page(object): ...@@ -84,11 +88,12 @@ class Page(object):
# 键盘ctrl+M,command+m # 键盘ctrl+M,command+m
def get_env_window(self): def get_env_window(self):
if platform.system().lower() == "windows": if platform.system().lower() == "windows":
ActionChains(self.driver).send_keys(Keys.CONTROL, "m").perform() # ActionChains(self.driver).send_keys(Keys.CONTROL, 'm').perform()
# ActionChains(self.driver).key_down(Keys.CONTROL).send_keys('m').key_up(Keys.CONTROL).perform()
self.find_element((By.XPATH, "//div[@id='root']")).send_keys(Keys.CONTROL, 'm')
elif platform.system().lower() == "darwin": elif platform.system().lower() == "darwin":
ActionChains(self.driver).send_keys(Keys.COMMAND, "m").perform() ActionChains(self.driver).send_keys(Keys.COMMAND, "m").perform()
# self.driver.find_element(By.XPATH, "//div[@class='title']").send_keys(Keys.COMMAND, "m")
# ActionChains(self.driver).key_down(Keys.COMMAND).send_keys("M").key_up(Keys.COMMAND).perform()
# 屏幕最大化 # 屏幕最大化
def max(self, *loc): def max(self, *loc):
......
...@@ -14,6 +14,8 @@ class LoginPage(Page): ...@@ -14,6 +14,8 @@ class LoginPage(Page):
password_input = (By.ID, "xmpwd") password_input = (By.ID, "xmpwd")
# 登录按钮 # 登录按钮
login_button = (By.CLASS_NAME, "submit") login_button = (By.CLASS_NAME, "submit")
# 选择环境窗口的关闭按钮
close_env_window_btn = (By.XPATH, "//span[@class='anticon anticon-close ant-modal-close-icon']")
# 验证元素 # 验证元素
# 店铺名称 # 店铺名称
...@@ -42,3 +44,7 @@ class LoginPage(Page): ...@@ -42,3 +44,7 @@ class LoginPage(Page):
def phone_input_execute_script(self): def phone_input_execute_script(self):
self.excute_script("form xm_phone_login") self.excute_script("form xm_phone_login")
# 关闭环境选择窗口
def click_close_env_window(self):
self.click(self.close_env_window_btn)
...@@ -24,16 +24,19 @@ class TestLoginPage(object): ...@@ -24,16 +24,19 @@ class TestLoginPage(object):
@pytest.mark.usefixtures("before_test_case") @pytest.mark.usefixtures("before_test_case")
def testLogin(self): def testLogin(self):
login_page = LoginPage(driver=self.driver) login_page = LoginPage(driver=self.driver)
login_page.get_env_window() login_page.sleep(1)
login_page.sleep(2) # 执行脚本,隐藏的手机号码输入框弹出
login_page.click_text(self.env) # login_page.phone_input_execute_script()
login_page.phone_input_execute_script() login_page.click_phone_login()
login_page.sleep(2)
# login_page.click_phone_login()
login_page.input_account(account=self.account) login_page.input_account(account=self.account)
login_page.input_password(password=self.password) login_page.input_password(password=self.password)
# login_page.get_env_window()
# login_page.click_what('span', 'text()', self.env)
# login_page.click_close_env_window()
login_page.click_login() login_page.click_login()
login_page.sleep(5) login_page.sleep(2)
login_page.click_text("取 消")
login_page.sleep(3)
# 校验是否存在店铺名称的元素 # 校验是否存在店铺名称的元素
assert login_page.ifElementExist(login_page.store_name) assert login_page.ifElementExist(login_page.store_name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment