我有一个 XPATH 库,用于 XPATH 定期更改的站点。我之所以编写它,是因为我无需遍历每个功能文件并更改它发送的 XPATH,而是可以简单地更改我在 .rb 库中拥有的变量的值。
是否可以通过 .feature 文件将这些常量传递给步骤定义?
.feature 功能文件示例:
Scenario: I want to test a button
When I go to url "blah"
And I click on the XPATH: XPATH_CONSTANT_VARIABLE
.rb 步骤定义示例:
When /^I click on the XPATH: {I DON'T KNOW WHAT TO PUT HERE}$/ do |path|
@driver.find_element(:xpath, path).click
end
示例 XPATH .rb 库:
XPATH_CONSTANT_VARIABLE = "//*[@id="blahblah"]/div[1]/div/div[2]/div/div[1]/div/div[5]/div/div/div/div[2]"