Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Selenium Bridge #3279

Open nevir opened 9 years ago

nevir commented 9 years ago

It's time.

Use cases:

indolering commented 8 years ago

I don't want to sound ungrateful for the work you guys do, but this is blocking functional testing. I tried solving this problem from the other end, using a standard Selenium library, but the shadow-dom screws up the query selectors and I couldn't translate them manually.

Maybe I could dance a jig and get the priority elevated a bit? Going on 1.5 years :cry:.

justinfagnani commented 8 years ago

Cab you give more information on what you need? Trying to pick up these issues is difficult with so little context.

indolering commented 8 years ago

I need to simulate filling in a form, clicking on submit, and checking on what is sent to my REST API. Polymer's on-* data-bindings just won't kick in when I use .click(). I can't even get it to notice when a dropdown has changed, I tried JQuery's .change() and YUI's input simulation library.

I can unit test individual functions and parse the dom, but it's very unproductive and brittle. Functional testing let's me test lots of components all at once. I can refactor several functions and test that things are still working without having to rewrite all of my tests.

It would be great if you could let me use Webdriver.io from within WCT or provide access to a Polyfilled selector from Selenium. Sorry, that statement doesn't make a whole lot of sense ;P. Let me try again: we need to be able to send WebDriver commands for things like manipulating the UI that can't be accomplished without Selenium's abstractions. Selenium has a raw JS API, but you could look into porting some of WebDriver.io's API, which wraps WebDriver's native commands in useful commands.

indolering commented 8 years ago

@justinfagnani, just to provide some context: the problem with functional testing outside of WCT is that the selector Selenium uses is isolated from the browser environment. This means you can't navigate the dom on browsers that don't implement the shadow-dom natively. I tried creating selectors that should work on polyfilled browsers, but Safari and IE refused to cooperate.

Update: I took another look at my code, saw some obvious mistakes, and I got a hacked selector working in Safari. I still need to test in IE and Edge, but I think I'll be able to do functional testing through wd.io.

kito99 commented 8 years ago

@indolering, how did this go? Any tips?

indolering commented 8 years ago

@kito99 Thanks for the ping, I've been meaning to write about this.

I think not supporting functional testing has created a blind spot.

For one, there are edge-cases which are falling through the cracks. In some instances, I can't get Chrome to click on buttons using Selenium directly. I have no idea why this only occurs in Chrome, it works in other browsers and I can get it working in Chrome using a naive implementation.

There are also plenty of utility functions from wd.io (like waitForExist) which are necessary when testing functionality that relies on data-binding. WCT could port most of the functionality from wd.io with minimal effort.

Finally, had Polymer supported functional testing from the get-go, I don't think we would have deprecated /deep/. I think deprecating deep is one of those decisions which sounded good to a committee but fails to give respect to people that just want to get things done. No longer can one just find an element on a page using a simple string of text (like waitForExist("controller /deep/ child /deep/ #data-bound-input")). No, we shouldn't use it everywhere, but it has its place.

@justinfagnani if Polymer wants to remove the need for frameworks to build modern web apps, well, we need to be able to test those apps functionally.

indolering commented 8 years ago

@kito99 Here's a function you can use to clean your selectors:

  function clean(selector){
    if(GLOBAL.nativeShadow){
      return selector;
    } else {
      return selector.replace(/\/deep\/|::shadow|>>>/g, "");
    }
  };
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.