How to send Keyboard keys in protractor like TAB

前端 未结 1 1925
盖世英雄少女心
盖世英雄少女心 2021-02-20 06:33

I need to select an element, send values to it, press tab and then send new values.

I can select the element and send values to it but am not being able to send TAB from

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-20 07:12

    i wrote a snippet and tested it against google.de (not .com! maybe you have to adjust this) and when sending TAB the next element gets the focus (in this case it's the search button).

    the snippet:

    describe('Test', function () {
      it('should browse to google', function () {
        browser.ignoreSynchronization = true;
        browser.driver.get('https://www.google.de');
        expect(browser.getCurrentUrl()).toEqual('https://www.google.de/');
      });
      it('should unfocus the search field', function () {
        var search = element(by.name('q'));
        search.sendKeys(protractor.Key.TAB);
        browser.sleep(3000); // 3s to take a look ;)
      });
    });
    

    0 讨论(0)
提交回复
热议问题