Select Element by class values

12 posts, 1 answers
  1. Martin Kulov
    Martin Kulov avatar
    9 posts
    Member since:
    Jan 2008

    Posted 17 Jul Link to this post

    Hi,

    Is it possible to define CSS selector for defining elements in Test Studio/Elements?

    I would like to select a html element based on more complex class values.

     

    Thank you!

     

     

  2. Nikolay Petrov
    Admin
    Nikolay Petrov avatar
    209 posts

    Posted 20 Jul Link to this post

    Hello Martin,

    Thank you for your question.

    Unfortunately such feature as CSS selectors is not available at the current state of the product.

    If there is a need to - automatically generated find logic of an element could be adjusted to wok properly using for example a chained expressions or using proper find expression statement. 

    I hope this answers to your question.

    Kind Regards,
    Nikolay Petrov
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Martin Kulov
    Martin Kulov avatar
    9 posts
    Member since:
    Jan 2008

    Posted 20 Jul in reply to Nikolay Petrov Link to this post

    Hi,

    What would be the best way to find controls in frameworks like EmberJS where HTML elements have dynamically changing IDs?

    So far I have identified CSS selectors to be one good option.

    Can chained expressions or find expression statement going to work?

     

    Thanks!

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    552 posts

    Posted 25 Jul Link to this post

    Hello Martin,

    Test Studio find expression is quite powerful even when the html elements has dynamic ids. This is because you could include any properties in the find expression to get a set of unique and static attributes to identify an element. 

    I am not sure if you are using only the Testing Framework or the full product but here are some further details about find expressions in code. 

    In case you would need any further assistance please share some specifics of the issue you are facing so that we could investigate the exact scenario.

    Thanks in advance for your understanding! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  5. Martin Kulov
    Martin Kulov avatar
    9 posts
    Member since:
    Jan 2008

    Posted 26 Jul in reply to Elena Tsvetkova Link to this post

    Dear Elena,

    I would like to search for an element defined by CSS selector like this:

    #myid div.class1.class2 div.class3.class4 div.class5

     

    This is the Selenium statement I am using right now:

    driver.FindElementByCssSelector("#myid div.class1.class2 div.class3.class4 div.class5");

     

    Can I do something similar with Test Studio?

     

    Thank you

     

     

     

  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    552 posts

    Posted 28 Jul Link to this post

    Hi Martin,

    Thank you for sharing your ideas.

    Though it is important to note that Test Studio is not supporting CSS selector so these could not be applied like you could in Selenium. 

    On the other hand Test Studio is using an intelligent element identification scheme which could be even more powerful than css selectors. Even if the elements have dynamic ids they probably could be identified by some of their other attributes and properties or a set of these which point to a unique element on page. Probably you could rely on text content, for example. 

    The chained find expression could be applicable and useful depending on the structure of the web page under test. In most cases there is a parent element which could be identified by a unique attribute among the rest elements and then could be used to narrow down the amount among which the required one should be identified. 

    If the above information does not provide sufficient information to accomplish your goals you could probably provide a sample application along with a scenario in which you are facing difficulties. This will be the easiest way to provide exact directions. 

    Thank you in advance for the cooperation! I am looking forward to hearing from you in case of any further queries. 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  7. Martin Kulov
    Martin Kulov avatar
    9 posts
    Member since:
    Jan 2008

    Posted 30 Jul in reply to Elena Tsvetkova Link to this post

    Hi Elena,

     

    It is not clear to me can I use intelligent element identification to select an item based on class values of its parent elements like in the css selector example below:

    #myid div.class1.class2 div.class3.class4 div.class5

     

    Do you have some similar functionality that I can use to select the same element that will get selected from the css selector example above?

    I understand that you do not support css selector syntax now.

    Do you have similar functionality that will help me select the same element based on css values of the element itself with combination of its parents?

     

    Thank you,

    Martin Kulov

     

     

     

     

  8. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    552 posts

    Posted 02 Aug Link to this post

    Hi Martin,

    Thanks for getting back to me. 

    Since css selectors are not supported you would not be able to rely on these to identify an element. Though you could use chained find expression in order to locate an element using attributes of both its parent element and the target element itself. 

    In case there is a certain difficulty you are facing you might want to share a sample application along with a test related to it. That way I will be able to provide more direct advice. 

    Thanks in advance for your understanding! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  9. Martin Kulov
    Martin Kulov avatar
    9 posts
    Member since:
    Jan 2008

    Posted 02 Aug in reply to Elena Tsvetkova Link to this post

    Hi Elena,

    As explained already, I have the following nested elements and corresponding attributes

     

    element 1 id - #myid

    element 2 type div style="class1 class2"

    element 3 type div style="class3 class4" 

    element 4 type div style="class5"

     

    How can I use chained find expression to find element 4 based on the attributes of all its parent elements and itself?

     

    Thank you!

     

     

     

  10. Answer
    Ivaylo
    Admin
    Ivaylo avatar
    760 posts

    Posted 07 Aug Link to this post

    Hello Martin,

    Let me interject into this ticket as Elena is out of the office.

    The closest Test Studio functionality of CSS selectors is using XPath in your find logic. Your find logic should look something like this:

    //div[@id='myid']/div[@style='class1 class2']/div[@style='class3 class4']/div[@style='class5']

    This is the complete relative XPath that you might be using.
    If the element you are looking for has unique attribute you can use simply:

    //div[@id='anotherdiv']

    Hope this helps.

    Regards,
    Ivaylo
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  11. Martin Kulov
    Martin Kulov avatar
    9 posts
    Member since:
    Jan 2008

    Posted 08 Aug in reply to Ivaylo Link to this post

    Thank you, Ivaylo!

     

  12. Ivaylo
    Admin
    Ivaylo avatar
    760 posts

    Posted 09 Aug Link to this post

    Hello Martin,

    You are most welcome.

    I have added a feature request, about adding CSS selectors in Test Studio's find logic. You can review the item and vote for it using this public link.

    Regards,
    Ivaylo
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top