nightwatch run e2e时想要匹配文字内容
但是css selector不能得到想要的结果,所以使用xpath
使用方法:
一、添加usePath配置
test_settings: { default: { selenium_port: 4444, selenium_host: ‘localhost‘, silent: true, globals: { devServerURL: ‘http://localhost:‘ + (process.env.PORT || config.dev.port) }, use_xpath: true }, ... }
二、使用
browser .useCss() .url(devServer) .waitForElementVisible(‘#app‘, 100000) .useXpath() .click(‘.//*[contains(concat(" ",normalize-space(@class)," ")," instance-dropdown-template ")]//li//span[contains(normalize-space(),"小型配置")]‘) .useCss() .click(‘.create-top .form-item:nth-child(4) input‘) .end()
三、csstopath代码如何写
https://css2xpath.github.io/