Here are some of the highlights of that solution. We created some additional extension methods for any web element to be able to perform some common functions. Because Selenium's FindElement normally only looks under an element, and we needed a way of looking above an element, we modified this hack using XPath parent axis. Another really useful function is the ability to extract table information.
public static class WebElementExtensions
{
public static IWebElement GetParent(this IWebElement element)
{
return element.FindElement(By.XPath("parent::*"));
}
public static IWebElement FindParentByClassName(this IWebElement element, string className)
{
if (element == null)
{
return null;
}
var classValue = element.GetAttribute("class");
if (classValue.Contains(className))
{
return element;
}
return FindParentByClassName(element.GetParent(), className);
}
public static List<string[]> ToTable(this IWebElement element)
{
var rows = new List<string[]>();
foreach (var tr in element.FindElements(By.TagName("tr")))
{
var thOrTds = tr.FindElements(By.TagName("th")).Union(tr.FindElements(By.TagName("td")));
rows.Add(thOrTds.Select(c => c.Text).ToArray());
}
return rows;
}
In addition to the normal page object model there are often times menus, or toolbars, that cross pages. The original way we did this was just to use the Base classes, but we soon started needing the base classes for things like steps in a wizard. So instead we moved those to extensions as well, based off the BasePage. So when we created a new page that used an exiting menu partial we could use the extension methods to call those the methods easily without any modifications. We found the easiest way to do this was based off empty interfaces, because extension methods don't really support attributes and we needed someway of describing which extension methods were legal on which objects.
public interface IHaveAdminMenu
{
}
public static class AdminMenuExtensions
{
public static void AdminMenuClickItems(this IHaveAdminMenu adminMenu)
{
var basePage = (BasePage) adminMenu;
basePage.Driver.FindElement(By.Id("itemsLink")).Click();
}
}
Great post, thanks a lot for sharing a valuable information.
ReplyDeletePlease keep sharing such more articles.
Best Selenium training in Chennai | Best Selenium training in Chennai
IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes. IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble.Final Year Projects for CSE
DeleteSpring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining .
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai
The Angular Training covers a wide range of topics including Angular Directives, Angular Services, and Angular programmability.Angular Training
Thanks for sharing the useful information with us. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
ReplyDeleteThanks
selenium training in velachery
It is a very nice article including a lot of viral content. I am going to share it on social media. Get the fireworks online / crackers online in chennai.
ReplyDelete
ReplyDeleteThis is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to article very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
DedicatedHosting4u.com
Thanks for sharing nice information with us. I like your post and all you share with us is up to date and quite informative,
ReplyDeleteThanks
Cpa offers
ReplyDeleteiso 27001 certification services
iso 27001 certification in delhi
ISO 9001 Certification in Noida
iso 22000 certification in Delhi
Thanks for posting keep updating it.
ReplyDeleteIonic Training in Chennai
Ionic Training
french courses in chennai
pearson vue
spoken english training in chennai
best english coaching centre in chennai
Blockchain Training in Chennai
Spoken English Course in Chennai
spanish institute in chennai
content writing training in chennai
Ionic Training in Tambaram
Ionic Training in Adyar
This is an awesome blog. Really very informative and creative contents. This concept is a good way to enhance the knowledge. Thanks for sharing.
ReplyDeleteOracle Training | Online Course | Certification in chennai | Oracle Training | Online Course | Certification in bangalore | Oracle Training | Online Course | Certification in hyderabad | Oracle Training | Online Course | Certification in pune | Oracle Training | Online Course | Certification in coimbatore
Liên hệ Aivivu, đặt vé máy bay tham khảo
ReplyDeletevé máy bay đi Mỹ giá rẻ
mua vé máy bay nha trang sài gòn
giá vé máy bay cần thơ đi hà nội
vé máy bay hà nội nha trang bamboo
vé máy bay đi đà lạt vietjet
xe taxi sân bay nội bài giá rẻ
combo nha trang giá rẻ