了解启动 Playwright 时的 With-As 命令
在与 Selenium + RobotFW 合作多年后,我正在尝试将 Playwright 和 RobotFW 集成在一起。
我的测试用例非常简单:
TEST_1 Check correctness of showing Login screen
[Tags] ui automated
Go to login screen normally
我定义了关键字如下:
with sync_playwright() as p:
browser = p.chromium.launch()
@keyword('Go to login screen normally')
def go_to_login_screen_normally():
page = browser.new_page()
page.goto("https://my.page.com/login")
print(page.title())
browser.close()
但它总是返回错误 Event Loop is close
但是,这个有效:
@keyword('Go to login screen normally')
def go_to_login_screen_normally():
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://my.page.com/login")
print(page.title())
browser.close()
意味着我必须将 With
> 进入函数部分。
我尝试跳过 With-As
但它不起作用。
感谢您的建议!
I'm trying to integrate Playwright and RobotFW together after spending years working with Selenium + RobotFW.
My test case is very simple:
TEST_1 Check correctness of showing Login screen
[Tags] ui automated
Go to login screen normally
I defined the keyword as below:
with sync_playwright() as p:
browser = p.chromium.launch()
@keyword('Go to login screen normally')
def go_to_login_screen_normally():
page = browser.new_page()
page.goto("https://my.page.com/login")
print(page.title())
browser.close()
But it always return the error Event loop is closed
However, this one works:
@keyword('Go to login screen normally')
def go_to_login_screen_normally():
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://my.page.com/login")
print(page.title())
browser.close()
Means I have to put the With
section into the function.
I tried to skip the With-As
but it does not work as well.
Thanks for your advices!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论