2

I want to verify that one screen string value with other screen string value. For example, if I try to select one product from the product list screen, the product detail screen is opened which is selected from the list. In this case, I want to verify the product name whether the selected product and opened product is the same or not by using protractor.

This is my Code:

productName = element(by.css('.item_name .ng-binding')).get(value).filter(function(text)
{
   if(productName.getText() == element.all(by.css('.LinesEllipsis')).get(1))
   {
      productName.click();
      expect(element.all(by.css('.LinesEllipsis')).get(1).isDisplayed()).toBeTruthy();
   }
}
  • 1
    Maybe I am reading the question wrong. Can't you store the strings in a variable and later compare them and make sure it is same ? – Sandeep Chandra Sekhar Feb 15 at 10:43
  • Sorry Bro, Before I update wrong code now I changed. Please check once and tell me what mistake I did here. – Mallikarjuna Sai Feb 15 at 13:20
  • It this code throwing an error? If so, please post that too. At a glance, it doesn't look like you have your declaration closed properly: productName = element(by.css('.item_name .ng-binding')).get(value).filter(function(text)). You are missing a ')' it looks like to me. – Brian Feb 15 at 15:33
  • What is 'get(value)' here? There are multiple syntax issues with this code. – Vishal Aggarwal Feb 16 at 11:42
0

I am new to the Protractor but in our software quality assurance company many teams are working on the protractor and I had faced the similar issues while automating the tests and had taken their help on the same. Hopefully below code snippet will work.

productName = element(by.css('.item_name .ng-binding')).get(value).filter(function(text)
{
   if(productName.getText() == element.all(by.css('.LinesEllipsis')).get(1))
   {
      productName.click();
expect(element.all(by.css('.LinesEllipsis')).get(1).isPresent()).toBe(true);
   }
}

Please do share your code with error if below code is not working. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.