在原生点击登录按钮,跳到网页,输入用户名密码,点击登录,跳回来
在 iOS 上使用 Robot Framework 进行自动化测试,并在原生应用程序中点击按钮,跳转到网页登录后,再从网页跳回来,需要执行以下步骤:
使用 Appium 或类似的工具连接到 iOS 设备或模拟器,并启动您要测试的应用程序。
在 Robot Framework 中编写测试用例,包括点击按钮以打开网页的步骤。
在测试用例中添加代码,使其等待加载网页。
执行登录步骤,包括在网页上输入用户名和密码,然后点击登录按钮。
从网页跳回到原生应用程序的步骤可能会因应用程序的实现而有所不同。如果应用程序使用 Safari View Controller 或类似的组件打开网页,则可以使用 Robot Framework 提供的“Switch Browser”关键字将控制权从浏览器切换回应用程序。
确认已成功返回原生应用程序后,执行后续的测试步骤,例如验证登录是否成功,等等。
请注意,这只是大致步骤,并且具体实现细节将根据您的应用程序和测试用例而有所不同。
*** Settings ***
Library AppiumLibrary
Library SeleniumLibrary
*** Variables ***
${appium_server} http://localhost:4723/wd/hub
${device_name} iPhone Simulator
${platform_name} iOS
${platform_ver} 14.0
${app_path} /path/to/your/app
${browser} safari
*** Test Cases ***
Login and Logout Test
Open Application ${appium_server} platformName=${platform_name} platformVersion=${platform_ver} deviceName=${device_name} browserName=${browser} app=${app_path}
Click Element login_button
Switch Browser title=Login Page
Wait Until Page Contains Element username_field
Input Text username_field myusername
Input Text password_field mypassword
Click Element login_button
Switch Browser
Wait Until Element Is Visible logged_in_message
Page Should Contain You are logged in!
Click Element logout_button
Wait Until Element Is Visible logged_out_message
Page Should Contain You are logged out!
Close Application
在上面的示例中,我们使用 AppiumLibrary 和 SeleniumLibrary 来连接到 iOS 设备或模拟器,并启动应用程序。然后,我们点击登录按钮,打开网页,并在网页上执行登录操作。然后,我们使用“Switch Browser”关键字将控制权切换回应用程序,验证登录是否成功,然后执行登出操作并关闭应用程序。
请注意,这只是一个示例,您需要根据您的具体应用程序和测试用例进行适当修改和扩展。
哇塞,大佬就是大佬,感谢,明天我回公司试试
我用chatgpt给你翻译的
答案不一定对,可以看下appium library的api
https://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html#Switch%20To%20Context
大佬,api里没有switch brower这个关键字
是不是得需要自己写关键字?
已解决,不需要转换,直接用inspector定位的元素进行输入点击操作
前两天咱们整体团建去了,给大家发消息啦,支持可能不及时。你能搞定挺好的。给你点个赞