我想单击网页上提供的许多链接中的一个链接,并且我写了一个代码,下面给出。所以任何人都可以告诉我,我们可以使用枚举或任何其他方式来点击特定的链接。作为回报,它会给页面对象。在C#Webdriver中,我想单击从网页上可用的许多链接中的一个链接
里面我是用带开关的情况下,有两个链接的代码,
public Object SelectMenu(string menuName)
{
Object result = null;
IWebElement menuTemp = driver.FindElement(By.XPath(".//a[contains(text(),'" + menuName + "')]"));
if (menuTemp.Enabled)
{
menuTemp.Click();
if (menu.ToUpper() == "COUNTRY")
{
result = new CountryPage(driver).Load();
}
else if (menu.ToUpper() == "PARTNER")
{
result = new PartnerPage(driver).Load();
}
看到我的代码,menuTemp是链接,如果der 30链接,所以我必须写30个案例,点击代码后,我们会回来作为您在ur代码中编写的页面的回报,它也可以减少dis代码。 – Harshit007