希望标题相当清楚,但是这里有更多细节:
A类包含一个ChromeDriver变量和对其进行操作的方法。我已经在代表菜单的A类中定义了B类,并且需要访问B类中A类的某些方法。
提出问题的另一种方式:如何在不创建A类另一个实例的情况下从B类(内部类)访问A类(外部类)?
我对C#还是很陌生,到目前为止,还没有找到实现此目的的方法,到目前为止,我的研究仅发现了死胡同。可能吗?如果没有,为什么不呢?
感谢您提供正确答案的答案和指示!
-更新-
很抱歉,延迟很长时间,在这种情况下,需要上述条件:
public sealed class CatalogPane
{
protected CatalogPane(Application application,string automationId,int index)
{
Pane = application.MainWindow.FindElementByClassname("CatalogMenu")
.Where(item => item.AutomationId().StartsWith(automationId))
.ElementAtOrDefault(index);
}
public AppiumWebElement Pane { get; set; }
public static class contextMenu
{
public static void Select(MenuOption option) // MenuOption has property id that holds an automationId
{
Pane.FindElementByaccessibilityId(option.id).Click(); // I do not have access to Pane so this is not possible. I would like to be able to do this.
}
}
}