更改Firefox Selenium Django / Python中的语言进行测试
我正在为Django / Python项目进行Firefox的本地硒行为。我的Firefox浏览器设置为英语,我通过手动浏览器访问本地网站。但是,当我使用Selenium进行行为测试时,浏览器是德语,以及我网站上选择的标准语言。当我使用修复此线程它将浏览器语言更改为英语,而不是网站的默认语言。这将是frefor_all脚本的代码:(
from selenium.webdriver import Firefox, FirefoxOptions
from selenium.webdriver.support.ui import WebDriverWait
def before_all(context):
"""Run once before any testing begins."""
options = FirefoxOptions()
options.set_preference('intl.locale.requested', 'en')
options.headless = False
context.driver = Firefox(options=options)
context.driver.implicitly_wait(5)
context.driver.set_window_size(1024, 768)
context.wait = WebDriverWait(context.driver, 30)
logging.disable(logging.ERROR)
问题在于,行为测试找不到德语按钮文本)
I am running local Selenium Behave tests on Firefox for a Django / Python project. My Firefox browser is set to English and I visit my local website via the browser manually everything is in English. However, when I run the Behave tests with Selenium, the browser is in German, as well as the standard language selected on my website. When I use the fix in this thread it changes the browser language to English but not the default language of the website. This would be the code of the before_all script:
from selenium.webdriver import Firefox, FirefoxOptions
from selenium.webdriver.support.ui import WebDriverWait
def before_all(context):
"""Run once before any testing begins."""
options = FirefoxOptions()
options.set_preference('intl.locale.requested', 'en')
options.headless = False
context.driver = Firefox(options=options)
context.driver.implicitly_wait(5)
context.driver.set_window_size(1024, 768)
context.wait = WebDriverWait(context.driver, 30)
logging.disable(logging.ERROR)
(The problem is that the behave tests do not find the German button texts)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论