[英]Pytest webdriver fixture can't introspect some options
My framework currently only has one conftest.py file in it, which contains a fixture called browser which returns the webdriver object to the test. 我的框架中目前只有一个conftest.py文件,其中包含一个称为浏览器的固定装置,该固定装置将webdriver对象返回到测试。 We've recently tried to implement metafunc.parametrize in _generate_configuration_ in order to test cross browser and cross platform on browserstack, and have encountered a problem. 我们最近试图执行,以测试对browserstack跨浏览器和跨平台_generate_configuration_ metafunc.parametrize,也碰到了问题。 When the browser fixture is called at the beginning of a ui test, it doesn't know what current browser/os/version the test is running in based on the metafunc.parametrize method. 在ui测试开始时调用浏览器固定装置时,它不知道基于metafunc.parametrize方法该测试在哪个当前浏览器/操作系统/版本中运行。
A nice example can be found here, but I like the idea of handling the webdriver object with a fixture because of how easy it is to handle the webdriver when it goes out of scope with the yield statement. 可以在此处找到一个很好的示例,但是我喜欢用固定装置处理webdriver对象的想法,因为当使用yield语句超出范围时,处理webdriver很容易。 It also DRYs up the code: https://qxf2.com/blog/selenium-cross-browser-cross-platform-pytest/ 它还会烘干代码: https ://qxf2.com/blog/selenium-cross-browser-cross-platform-pytest/
Webdrivers as fixtures are a great approach that I highly recommend, particularly because you get free teardown and driver.quit() once your tests have completed. 我强烈建议将Webdrivers作为固定装置,这是一种极好的方法,特别是因为一旦测试完成,您将获得免费的拆解和driver.quit()。 If your driver is going to be dealing with different versions/browsers, I highly recommend you do the following: 如果您的驱动程序要使用不同的版本/浏览器,我强烈建议您执行以下操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.