質問

This seems kinda basic but it has been giving me nothing but trouble. I have a UL LI list that I have styled as tabs. When I test in browser when I click and give focus to the second tab then click the TAB key on the keyboard and enter it gives focus to the 3rd tab and selects it.

I am trying to simulate this using WebDriverJS with the following coffeescript code in my test using chai, onecolor, etc. The part is that giving me the problem is with I can get all normal characters to go fine but none of the special characters seems to work in my sauce labs selenium using this documentation JSON WIRE PROTOCOL. The implementation I am using is from http://webdriver.io/ and the tests are running in https://saucelabs.com/.

  it 'tab key and enter works', (done) ->
    @timeout 10000
    @driver.waitFor '.tab.active', 10000, =>
      @driver.addValue '.tab:nth-child(2)', ['U+E004', 'U+E007'], (err) =>
        @driver.getElementCssProperty 'css selector', '.tab:nth-child(3)', 'background-color', (err, backgroundColor) =>
          @driver.getElementCssProperty 'css selector', '.tab:nth-child(3)', 'color', (err, color) =>
            onecolor('#ffffff').cssa().should.equal backgroundColor
            onecolor('#000000').cssa().should.equal color
            done()
役に立ちましたか?

解決

You can use all kinds of unicode characters. To do so you need to set the name of the key as input value (case sensitive). For example:

client.addValue('.tab:nth-child(2)',['Tab','Enter']) // press TAB + ENTER

or

client.addValue('.tab:nth-child(2)',['Meta','c']) // copy text into clipboard

If you don't want to link the keypress action to any input field you can use the keys protocol command to do this action:

client.keys(['Meta','c'])
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top