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

Validate visibility of elements inside a row table - Chained locators #187

Closed
jdmesalosada opened this issue Mar 13, 2018 · 1 comment
Closed
Labels
awaiting feedback documentation question @serenity-js/protractor

Comments

@jdmesalosada
Copy link

@jdmesalosada jdmesalosada commented Mar 13, 2018

Hi everyone,
I have the following due regarding how to find an element starting from another element and then make assertions in those elements. For example something like this in protractor:

element(by.css('some-css')).all(by.tagName('tag-within-css'));
or
element(by.css('some-css')).element(by.tagName('tag-within-css'));

So I have a table. Let say the table container is div.table-container, the rows are identified by the class: div.row-identifier.
Inside each row I have several elements that I want to know if they are displayed. So I have to get all the row elements, and then search inside that element the others elements.

My seudo looks like:

const table-container = "table-container";
const row-container = "row-container";

const element1InsideRow = "element1InsideRow";
const element2InsideRow = "element2InsideRow";

var allRowsElements =  table-container.find(row-container);//here I search the rows starting the table.

foreach(rowElement in allRowsElements){
Assert.IsDisplayed(rowElement.find(element1InsideRow )); //Now I search the element 1 starting the row
Assert.IsDisplayed(rowElement.find(element2InsideRow));

}

Thanks in advanced.

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Mar 18, 2018

Hey @jdmesalosada! Support for nested targets has been proposed under #143 and that could be helpful, but I'd suggest looking into the Journey Planner example. I've created a custom question there which maps a table row to something a bit more meaningful - a JourneySummary.
With that model in place, I wrote a custom assertion, which you can find being used here.

Does that help?

Jan

@jan-molak jan-molak added question documentation awaiting feedback labels Mar 18, 2018
@jan-molak jan-molak added the @serenity-js/protractor label Jul 26, 2018
@jan-molak jan-molak added this to the 2.0 milestone Feb 19, 2019
jan-molak added a commit that referenced this issue Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback documentation question @serenity-js/protractor
Projects
None yet
Development

No branches or pull requests

2 participants