Exemplo n.º 1
0
 public void Action_SelectElementByClassname(string Classname, ElementItem refElementItem)
 {
     try
     {
         if (Classname != "" && refElementItem != null)
         {
             int tryCount = _tryCount;
             while (tryCount > 0)
             {
                 IWebElement selectedElement = _activeWebDriverObj.FindElement(By.ClassName(Classname));
                 if (selectedElement != null)
                 {
                     if (!refElementItem.ElementFindMap.ContainsKey(HtmlFindMapType.byTag))
                         refElementItem.ElementFindMap.Add(HtmlFindMapType.byClassName, Classname);
                     else
                         refElementItem.ElementFindMap[HtmlFindMapType.byClassName] = Classname;
                     refElementItem.ElementTag = selectedElement.TagName;
                     refElementItem.refElement = selectedElement;
                     break;
                 }
                 else
                 {
                     Thread.Sleep(_retryEachTime);
                     tryCount--;
                 }
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
 public ElementActions(ElementItem selectedElementItem)
 {
     _selectedElementItem = selectedElementItem;
 }
Exemplo n.º 3
0
 public void Action_SelectElementByXPATH(string XPATH,ElementItem refElementItem)
 {
     try
     {
         if (XPATH != "" && refElementItem!=null)
         {
               int tryCount = _tryCount;
               while (tryCount > 0)
               {
                   IWebElement selectedElement = _activeWebDriverObj.FindElement(By.XPath(XPATH));
                   if (selectedElement != null)
                   {
                       if (!refElementItem.ElementFindMap.ContainsKey(HtmlFindMapType.byXpath))
                           refElementItem.ElementFindMap.Add(HtmlFindMapType.byXpath, XPATH);
                       else
                           refElementItem.ElementFindMap[HtmlFindMapType.byXpath] = XPATH;
                       refElementItem.ElementTag = selectedElement.TagName;
                       refElementItem.refElement = selectedElement;
                   }
                   else
                   {
                       Thread.Sleep(_retryEachTime);
                       tryCount--;
                   }
               }
         }
      }
     catch
     {
     }
 }
Exemplo n.º 4
0
 public ElementItem Action_SelectElementByXPATH(string XPATH)
 {
     try
     {
         if (XPATH != "")
         {
             int tryCount = _tryCount;
             while (tryCount > 0)
             {
                 IWebElement selectedElement = _activeWebDriverObj.FindElement(By.XPath(XPATH));
                 if (selectedElement != null)
                 {
                     ElementItem newElementItem = new ElementItem();
                     newElementItem.ElementFindMap.Add(HtmlFindMapType.byXpath, XPATH);
                     newElementItem.ElementTag = selectedElement.TagName;
                     newElementItem.refElement = selectedElement;
                     return newElementItem;
                 }
                 else
                 {
                     Thread.Sleep(_retryEachTime);
                     tryCount--;
                 }
             }
             return null;
         }
         else
             return null;
     }
     catch
     {
         return null;
     }
 }
Exemplo n.º 5
0
 public void Action_SelectElementByLinkText(string LinkText, ElementItem refElementItem)
 {
     try
     {
         if (LinkText != "" && refElementItem != null)
         {
             int tryCount = _tryCount;
             while (tryCount > 0)
             {
                 IWebElement selectedElement = _activeWebDriverObj.FindElement(By.LinkText(LinkText));
                 if (selectedElement != null)
                 {
                     if (!refElementItem.ElementFindMap.ContainsKey(HtmlFindMapType.byLinkText))
                         refElementItem.ElementFindMap.Add(HtmlFindMapType.byLinkText, LinkText);
                     else
                         refElementItem.ElementFindMap[HtmlFindMapType.byLinkText] = LinkText;
                     refElementItem.ElementTag = selectedElement.TagName;
                     refElementItem.refElement = selectedElement;
                     break;
                 }
                 else
                 {
                     Thread.Sleep(_retryEachTime);
                     tryCount--;
                 }
             }
         }
     }
     catch
     {
     }
 }