Thursday 10 November 2016

Types of UI elements..!!!

Hi

Today we will be learning types of UI element in selenium webdriver

1. ByID                -          Locates element using value of their "ID" attribute.
                                        Ex- driver.findElement(By.id("i1"));

2. ByClassName   -         Locates element using value of their "class" attribute.
                                        Ex- driver.findElement(By.className("hello"));

3. ByName            -        Locates element using value of their "name" attribute.
                                        Ex- driver.findElement(By.name("txtname"));

4. ByLinkText        -       Finds the link element by the exact text it displays
                                        Ex- driver.findElement(By.linkText("hey"));

5. By.CSS             -         Find element based on the CSS selector engine
                                        Ex- driver.findElement(By.cssSelector("input#mail"));

1. By.xpath            -        Locates element via Xpath
                                       Ex- driver.findElement(By.xpath("/html/body/div[3]/a"));
                 
                 
                 
                 
                 
                 


2 comments: