0

我是完美移动设备自动化的新手。我遇到了一个名称字段,它在应用程序的两行中返回值。像下面

School Name : ABCD
              INTERNATIONAL

我发现定位器是 Xpath 为 //*[text()="ABCD INTERNATIONAL"],它在两行中返回值,当我运行代码并断言该值时,我确认了这一点。所以基本上错误如下

expected [ABCD INTERNATIONAL] but found [ABCD
INTERNATIONAL]

我的功能文件就像

Feature: Verify the school Details
Scenario : Verify the school Name
Given User logs into Application
When User verifies the school name as "ABCD INTERNATIONAL"
Then user logs of

步骤防御:

@When("User verifies the school name as {string}")
    public void a_User_verifies_the_school_name_as (String Name) throws Exception {
         String School_Name = utility.getText(appiumDriver, "//*[text()="ABCD INTERNATIONAL"]);
           Assert.assertEquals(School_Name, Name);
    }

您对解决这个问题的帮助意义重大。

4

1 回答 1

0

我认为您必须使用 replaceAll() 方法修改实际和预期的字符串。

像 replaceAll("\n",""); 并替换所有(“”,“”)。然后在断言中比较两者。如果它不起作用,那么您必须通过正则表达式使用模式匹配。

于 2021-03-26T17:49:43.727 回答