0

I am having trouble seeing the methods from one of the class. I have created a MobileLoginPage class and I want to click the Menu button. I noticed there is already a method defined to click the Menu button from a class called MobileNavigationPage. The method is called ClickMenuNavigation

As this method already exists I should be able to call it from my MobileLoginPage class. Avoid duplicating code. I am not able to call it, when i write the code MobileNavigationLogin. no methods show up. I even tried to call the locator element by defining a method (getMenuNavigationElement) to return the locator. I cannot see this locator from LoginPage class.

The class has been instantiated in the BasePage class, I do not know why I cannot see it's methods.

My code snippet is:

The BasePage is and all of our classes are instantiated here:

public class BasePage : SpecflowBaseTest

{
    internal MobileNavigationPage MobileNavigationPage => new 
    MobileNavigationPage(Browser);
    internal MobileLoginPage MobileLoginPage => new 
    MobileLoginPage(Browser);
}

The MobileNavigationPage is:

public void MobilenavigationPage : BasePage
{
    #region Elements

    [FindsBy(How = How.Id, Using = "MobileMenuNavigation")]
    private IWebElement MenuButton {get; set;}

    #endregion

    #region Actions

    private void ClickMenuNavigation()
    {
        Actions.Click.Element(Browser, MenuButton);

    }

    private IWebElement getMenuNavigationElement()
    {
        return MenuButton;
    }

    #endregion 
}

The MobileLoginPage is:

public class MobileLoginPage : BasePage
{
    # region Actions

    public void ClickBrandFromMenuNavigation{}
    {
        // I want to call ClickMenuNavigation() from here                   
    }

    #endregion
}

From LoginPage class how do I call the method which is defined in MobileNavigationPage?

1 Answer 1

1

The method is private which means it can only be used within a MobilenavigationPage.

You can make it public though, and then it will show up --

public void ClickBrandFromMenuNavigation()
{
    base.MobileNavigationPage.ClickMenuNavigation();                   
}
Sign up to request clarification or add additional context in comments.

4 Comments

I have tried making it public and tried with protected also. It still does not show up
ah, I have not tried with base.MobileNavigationPage. I will try with this
sorry, that still does not work. If i type base. It does not see MobileNavigationPage. I made the method public
Is the BasePage in the same assembly? Try making its properties public (or at least protected) too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.