Java 数据中包含场景大纲和引号的功能文件
我在一个功能文件中有一个场景,在这个场景中,我收到一条消息,要用引号进行验证。请看以下示例:Java 数据中包含场景大纲和引号的功能文件,java,selenium,selenium-webdriver,cucumber-jvm,Java,Selenium,Selenium Webdriver,Cucumber Jvm,我在一个功能文件中有一个场景,在这个场景中,我收到一条消息,要用引号进行验证。请看以下示例: Scenario Outline: Testing xyz Give you are a valid user When you log in to the System as Richard Then you will be welcomed with "<Msg>" Examples: | Msg | | Welcome to this application "Richard" |
Scenario Outline: Testing xyz
Give you are a valid user
When you log in to the System as Richard
Then you will be welcomed with "<Msg>"
Examples:
| Msg |
| Welcome to this application "Richard" |
输出:
欢迎使用此应用程序
请注意,arg参数不包含带引号的单词“Richard”。但是商业规则规定,消息的名称周围应该有引号
有谁能帮我写这个功能文件,这样我就可以在参数中用引号得到“Richard”这个词了吗
我正在使用Java+Selenium+CucumberOk。我找到了解决办法。在Cumber文件中,我将放一个报价单。因此示例:| Msg | |欢迎使用此应用程序“Richard”|在存根方法中,我将用双引号替换所有单个代码,然后进行验证。所以@Then public void欢迎使用此应用程序Richard(String arg){System.out.println(arg.replace(“'”,“\”);}您根本不需要使用引号:)就足够了
@Then
public void Welcome to this application Richard(String arg){
System.out.println(arg);
}