In my code there a list of elements (tr) selected with "protractor.By.repeater". This list is looped using "forEach".
Within this loop, the element is clicked, and this click should trigger the inclusion of a new "tr" just after the clicked element.
I want to select that new line.
I used :
var nextRow = tr.$(protractor.By.xpath('following-sibling::tr'));
but then with :
nextRow.isDisplayed(function(row){
console.log('row', row);
});
it generates errors such as : " UnknownError: java.util.HashMap cannot be cast to java.lang.String"
Is there another way to achieve what I want, i.e to select the next sibling of the current element ?
Or did I wrote something incorrect there ?
Thanks for any help!
Looks like you are missing a .then
there and misinterpreted what isDisplayed does.
Code should be more like:
nextRow.isDisplayed().then(function(visible) {
console.log('is displayed? ', visible);
});
Also your ElementFinder nextRow
doesn't look quite alright, what is variable tr
below? and Protractor $
is an alias for element(by.css
which takes a string argument, not a webdriver.Locator like you interpreted below, in your code:
var nextRow = tr.$(protractor.By.xpath('following-sibling::tr'));
So instead maybe you meant:
var tr = $('table tr.first'); // just guessing here since you didn't provide that code
var nextRow = tr.element(By.xpath('following-sibling::tr'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With