当您从其他地方提取元素时,验证 order/make 最多 URL

Verifying the order/make up of URL, when you have the elements extracted from elsewhere

我想验证从开发网站上的分面导航生成的 URL 的顺序。

EG http://EcomWebsite.com/region/s/element1/element2/element3

作为不同测试步骤的一部分,我提取了我需要的字符串,我可以测试这些字符串是否存在于 url 中。我一直这样做

assertThat(displayShopPage.getCurrentURL(),containsString(displayShopPage.element1()));
assertThat(displayShopPage.getCurrentURL(),containsString(displayShopPage.element2()));
assertThat(displayShopPage.getCurrentURL(),containsString(displayShopPage.element3()));

但我提到我需要检查 URL 的顺序。

有问题的步骤是

"Then the order in which the values are included in the URL must be same order the values have within the facet"

我对 Java、Selenium 和 BDD 还是比较陌生,所以感谢您提供的任何帮助。

编辑: 我试图避免硬编码 url 以及我想在 URL 中检查的内容,原因有几个。

Element1 等来自 class,它从分面导航元素选项中提取文本。

因此,如果我对 URL 或元素选项中的文本进行硬编码,如果产品数据发生变化,那么分面导航将破坏测试。

因此,为什么我要从元素中提取字符串以与 URL 进行比较,而不是仅仅检查 URL 本身。

getCurrentURL() returns 一个字符串,对吧?为什么不简单地将预期的 URL 组合成一个字符串然后比较这些字符串呢?

currentUrl = displayShopPage.getCurrentURL()
expectedUrl = "http://EcomWebsite.com/" + displayShopPage.CF_PanelText() + "/s/" + displayShopPage.FacetGroup2OptionPanelText()   # compose this from your page source...it isn't clear above what the component order needs to be
assertEquals(currentUrl, expectedUrl)  # I made this up, I don't know the proper syntax for comparing strings