1
votes

On page https://about.google/intl/en/commitments/reports/ I want to click on Footer link "Press inquiries" Can anyone help me in creating a chain locator in protractor for the same. I want to click on it. I myself created below. I know it is wrong I am getting errors for it.

await element(by.css("ul[id='footer-sitemap-links']"))

.element(by.css("li:nth-child(2)"))

.element(by.css("div[css='1']"))

.element(by.css("div[id='footer-sitemap-related-content']"))

.element(by.css("div[class='glue-c-zippy__content-container']"))

.element(by.css("li:nth-child(1)"))

.click();

screenshot for element

1

1 Answers

0
votes

Below is the locator provided by you and it's not accurately finding the correct locator

await element(by.css("ul[id='footer-sitemap-links']"))

.element(by.css("li:nth-child(2)"))

.element(by.css("div[css='1']"))

.element(by.css("div[id='footer-sitemap-related-content']"))

.element(by.css("div[class='glue-c-zippy__content-container']"))

.element(by.css("li:nth-child(1)"))

.click();

.element(by.css("li:nth-child(2)") this locator causes issue as there are 5 different elements matching this locator. and then everything goes wrong.

I have created CSS chain to find the desired element

await element(by.css("#footer-sitemap-links")
.element(by.css("#footer-sitemap-related")
.element(by.css("li a[data-g-label*='Press inquiries']")
.click();

Or simply you can just do

await element(by.cssContainingText("a","Press inquiries")).click();

and it will work

Happy coding~