[英]robot test cases passing formatted variables from python to robot file
你能幫我有沒有辦法將格式化字符串從 python 文件傳遞到機器人文件假設下面是我的特定語言 py 文件
English.py 文件分配了以下變量
FILTERED_TEXT_LANG = "{} Selected"
機器人測試用例設置變量如下機器人文件(user.robot)
${element} = Set Variable xpath=*//div[contains(@id,'org-selection-counter') and contains(text(),'${FILTERED_TEXT_LANG}.format(some_filtered_count)')]
這是必需的,因為不同的語言以不同的方式顯示 some_filtered_count,有沒有辦法可以從字符串格式的更改而不是其他條件
好吧,有一種方法,但不是這樣:
${element} = Set Variable xpath=*//div[contains(@id,'org-selection-counter') and contains(text(),'${FILTERED_TEXT_LANG}.format(some_filtered_count)')]
您不能直接在 RF 中使用 Python 關鍵字、方法等。 但是您可以做的是在 RF 或 Python 中創建您的自定義關鍵字,您稍后在 RF 中使用它,它將在字符串中填充一種語言。 實際上,您甚至不需要創建任何內容,只需重用String 庫中已有的內容即可
我可以想象這樣的事情:
${str_with_language}= Replace String ${FILTERED_TEXT_LANG} {} ENG
${element} = Set Variable xpath=*//div[contains(@id,'org-selection-counter') and contains(text(),'${str_with_language}')]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.