Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need info how to test polymer elements using Selenium. #948

Closed
karanahuja007 opened this issue Nov 20, 2014 · 9 comments
Closed

Need info how to test polymer elements using Selenium. #948

karanahuja007 opened this issue Nov 20, 2014 · 9 comments

Comments

@karanahuja007
Copy link

Hi All,

I have used polymer elements in my project, but when I was automating it using Selenium I feel I was not able to access Shadow Dom objects.
Is there any other alternative to access Shadow DOM objects?

@davidmaxwaterman
Copy link

You can usually access them using the element's 'shadowRoot' object. eg:

document.querySelectorAll('my-element')[0].shadowRoot.querySelectorAll('sub-element')[0]

I suppose I might have misunderstood your question or Selenium complicates things somehow. If so, perhaps you can give an example of something that doesn't work so we can understand the issues.

@karanahuja007
Copy link
Author

Selenium is a tool used for Automation testing, It finds the locator(attribute tagname) using Xpath or JavascriptExecuter or Csslocator.
It finds everything on the page but it return null when we try to access inside polymer element.
I need to automate test-cases, do we have any solution for it?

@davidmaxwaterman
Copy link

Hrm, thanks for clarifying. In the absence of anyone else commenting, I would say that Selenium needs to be able to do the equivalent of querySelectorAll('html /deep/ my-element'). If you can specify that it use '/deep/' then perhaps there is some hope.

@dhubler
Copy link

dhubler commented Nov 20, 2014

Chiming in as I've been following selenium/shadowdom support for a while.
There was a draft...

http://www.w3.org/TR/webdriver/#switching-to-hosted-shadow-doms

but unless i missed something, progress has not moved from what i've seen
in a while which is concerning. Shedding some light on this issue would be
great.

On Thu, Nov 20, 2014 at 1:02 PM, Max Waterman [email protected]
wrote:

Hrm, thanks for clarifying. In the absence of anyone else commenting, I
would say that Selenium needs to be able to do the equivalent of
querySelectorAll('html /deep/ my-element'). If you can specify that it use
'/deep/' then perhaps there is some hope.


Reply to this email directly or view it on GitHub
#948 (comment).

@davidmaxwaterman
Copy link

wrt to my mention of /deep/ - it was mentioned on the polymer panel at the chrome dev summit today. There seemed to be a, dare I say it, /negative/ feeling towards that - and also the shadowRoot property - and that they should try to find some other way to avoid this kind of 'violation' of the encapsulation. Though there was a comment that it was more because implementing /deep/ and shadowRoot was actually difficult in terms of achieving good performance.
Take that as you will...
Perhaps the conclusion from that is that testing tools shouldn't 'go deep' and test components/elements individually - ie treat the elements as if they were native elements.

@karanahuja007
Copy link
Author

Hmm.. Thanks for the reply.

@nmondal
Copy link

nmondal commented Jun 15, 2015

I might be late, very late.
But apparently - polymer stuffs are not changing anything - so as much!
Take for example the web site built on Polymer : http://1.daily-stock-forecast.appspot.com
Selenium is able to run through it. In nJexl the code is this :

    /*
 Tests the polymer sample :
 http://1.daily-stock-forecast.appspot.com
*/
import 'java.lang.System.out' as out 
import 'java.lang.Thread' as Thread

selenium.open("/") ;  ## Open the URL 

@@selenium.click("search-dialog-button")

@@selenium.type("symbol_search" , "MSFT\n")

Thread.sleep(6000)

I can see that the UI is properly automated!

@letsenzoy
Copy link

Any updates on this?

@huanleapp
Copy link

Hi
For clarifying selenium.
I can run Selenium (firefoxDriver) to get element and control a element i want
But, i can use ChromeDriver for that.
what is it deference between Firefox and chrome ? are there more way to automation test by Selenium on website's polimer (ex: https://shop.polymer-project.org/)
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants