亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JBehave Serenity:如何管理 baseURL 和相對 URL?

JBehave Serenity:如何管理 baseURL 和相對 URL?

哈士奇WWW 2021-11-17 17:26:16
我是 Serenity 的新手,我了解到我們可以從命令行更改默認 URL。這就是我聲明默認 URL 的方式@DefaultUrl("http://en.wiktionary.org/wiki/Wiktionary")public class DictionaryPage extends PageObject {}但是對于每個頁面,如果我繼續像這樣聲明 URL,我最終會失去聲明默認 URL 的概念。我正在尋找的是我只是在某處指定默認 URL 并提供這樣的相關頁面 URL:@DefaultUrl($baseURL+"/wiki/Wiktionary")public class DictionaryPage extends PageObject {}我怎樣才能做到這一點?serenity.properties如下所示:# Define the default driver#webdriver.driver=phantomjs# Appears at the top of the reportsserenity.project.name = Demo Project using Serenity and JBehaveserenity.restart.browser.for.each = NEVER# Root package for any JUnit acceptance tests#serenity.test.root=net.thucydides.showcase.junit.features# Customise your requirements hierarchy#serenity.requirement.types=feature, story# Run the tests without calling webdriver - useful to check your JBehave wireing#serenity.dry.run=true# Customise browser size#serenity.browser.height = 1200#serenity.browser.width = 1200
查看完整描述

2 回答

?
富國滬深

TA貢獻1790條經驗 獲得超9個贊

在 serenity.properties 文件中輸入以下屬性


webdriver.base.url = http://en.wiktionary.org


在您的頁面對象中,像這樣定義 DefaultUrl


@DefaultUrl("/wiki/Wiktionary")

public class DictionaryPage extends PageObject {



}

Serenity 將在調用 DefaultUrl 時構造完整的 URL。


有關 serenity.properties 中所有可用屬性的進一步參考,請參閱以下鏈接 https://github.com/serenity-bdd/serenity-documentation/blob/master/src/asciidoc/system-props.adoc


查看完整回答
反對 回復 2021-11-17
?
翻閱古今

TA貢獻1780條經驗 獲得超5個贊

除此之外,我認為您可以在頁面對象中使用別名,如下所示:


@DefaultUrl("/wiki/Wiktionary")

@NamedUrls({

    @NamedUrl(name = "glossary", url = "/wiki/Appendix:Glossary"),

    @NamedUrl(name = "community_portal", url = "/wiki/Wiktionary:Community_Portal")

})

public class DictionaryPage extends PageObject {}

并在您的步驟中使用它們:


public class EndUserSteps {


    DictionaryPage dictionaryPage;


    @Step

    public void navigatesUsingDeepLink() {

        dictionaryPage.open("productId_1");

    }

}


查看完整回答
反對 回復 2021-11-17
  • 2 回答
  • 0 關注
  • 179 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號