Skip to content

Instantly share code, notes, and snippets.

@bootstraponline
Last active December 20, 2015 03:28
Show Gist options
  • Save bootstraponline/6063355 to your computer and use it in GitHub Desktop.
Save bootstraponline/6063355 to your computer and use it in GitHub Desktop.
JavaScript vs Ruby

Ruby

scroll_to('views').click
scroll_to('tabs').click
scroll_to('content by id').click
s_text(0).selected?.must_equal false
s_text(1).selected?.must_equal true

JavaScript

describeWd('get attribute selected', function(h) {
  it('should be able to get selected value of a tab', function(done) {
    h.driver.execute("mobile: find", [["scroll",[[3, "views"]],[[7, "views"]]]], function(err, el) {
      should.not.exist(err);
      el.click(function(err) {
        h.driver.execute("mobile: find", [["scroll",[[3, "tabs"]],[[7, "tabs"]]]], function(err, el) {
          should.not.exist(err);
          el.click(function(err) {
            h.driver.execute("mobile: find", [["scroll",[[3, "content by id"]],[[7, "content by id"]]]], function(err, el) {
              should.not.exist(err);
              el.click(function(err) {
                h.driver.elementsByTagName("text", function(err,els) {
                  should.not.exist(err);
                  els[0].getAttribute('selected', function(err, selected) {
                    should.not.exist(err);
                    selected.should.equal(false); // the 1st text is not selected
                    els[1].getAttribute('selected', function(err, selected) {
                      should.not.exist(err);
                      selected.should.equal(true); // tab 1 is selected
                      done();
                    });
                  });
                });
              });
            });
          });
        });
      });
    });
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment