gpt4 book ai didi

java - 使用多个示例时如何在 Cucumber 功能中参数化用户名和密码

转载 作者:行者123 更新时间:2023-12-02 09:04:58 24 4
gpt4 key购买 nike

我正在使用 Cucumber+Selenium+junit 来自动化测试用例。

下面提到了示例场景。我将不同环境的多个示例传递到场景中。在我的测试应用程序中,密码每 60 天就会更改一次,并且在每个功能文件中更新这些密码非常麻烦。您能否帮助我如何参数化这些用户名和密码并从单独的配置文件传递它们,以便每次密码更改时我都可以在一个位置更新它们。

Scenario Outline: Verify the login functionality in xyz application

Given I open the browser

And I launch the xyz application <url>

When I enter the <username> and <password>

And click on sign in button

Then User should login successfully

Examples

@SIT

|url |username |password|

|sit.com|situser|sitpassword|



@UAT

|url |username |password|

|uat.com|uatuser|uatpassword|



@Training

|url |username |password|

|training.com|traininguser|trainingpassword|

最佳答案

只编写不包含凭据的场景。然后在步骤定义中获取密码

你可以写这样的场景

Given I am registered on UAT
When I login into UAT
Then I should be logged in

然后类似

module EnvTesterSH
def get_current_creds(env: )
...
[id, password]
end
end
World EnvTesterSH

Given 'I am registered on UAT' do
@id, @password = get_current_creds(env: :uat)
end

现在你的问题是如何编写代码来获取新的凭据,我想这完全取决于谁或什么更改了凭据。但现在你至少有一种编程语言可以帮助你。

关于java - 使用多个示例时如何在 Cucumber 功能中参数化用户名和密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59892945/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com