TestStack / TestStack.Seleno

Seleno helps you write automated UI tests in the right way by implementing Page Objects and Page Components and by reading from and writing to web pages using strongly typed view models.
http://teststack.github.com/TestStack.Seleno/
MIT License
180 stars 60 forks source link

Navigate.To<Page>(By.LinkText) with multiple equal link texts #254

Closed happymonkey closed 7 years ago

happymonkey commented 7 years ago

Hey! I have a question with Navigate.To<SomePage>(By.LinkText("linkText" ) . In my web page there is a link with the same text to the same page both in the menu and in the footer. I want to navigate to that page by the link that is in the footer not in the menu. I guess Navigate.To<SomePage>(By.LinkText("linkText" ) chooses the first link which is the menu link but how can I make it choose the other link? If I had a code like this:

public void NavigateToSomePageByFooter()
        {
            var footerItems= Find.Element(By.ClassName("footer"));
            var footerItemToClick= footerItems.FindElement(By.LinkText("linkText"));
            footerItemToClick.Click();
        }

That would navigate me to the wanted page by footer link, but it would not return me the page. And Seleno does not allow returning new Page Object. How can I navigate to page with multiple equal link texts?

robdmoore commented 7 years ago

Try return GetComponent();

On 5 Oct 2016, at 7:12 PM, happymonkey notifications@github.com wrote:

Hey! I have a question with Navigate.To(By.LinkText("linkText" ) . In my web page there is a link with the same text to the same page both in the menu and in the footer. I want to navigate to that page by the link that is in the footer not in the menu. I guess Navigate.To(By.LinkText("linkText" ) chooses the first link which is the menu link but how can I make it choose the other link? If I had a code like this:

public void NavigateToSomePageByFooter() { var footerItems= Find.Element(By.ClassName("footer")); var footerItemToClick= footerItems.FindElement(By.LinkText("linkText")); footerItemToClick.Click(); } That would navigate me to the wanted page by footer link, but it would not return me the page. And it is not possible to just return new instance of that page. How can I do the same thing but also return the page?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

happymonkey commented 7 years ago

Ok, thanks! That works. So basically this Navigate.To<SomePage>(By.LinkText("linkText" ) does not allow to specify more?