Selenium- basic understanding - the composition and positioning elements


Selenium composition
    selenium1.0

selenium IDE

WebDriver

Build automated testing framework

Selenium basis

    Positioning objects WebDriver

        WebDriver driver=new FirefoxDriver(); //定义一个firefox的WeDriver对象
        driver.manage().window().maximize();    //最大化浏览器窗口
        driver.navigate().to("file:///C:/Users/LW/Desktop/aaa.html");  //访问地址


    Positioning elements


        ID positioning

        driver.findElement(By.id("fname")).sendKeys("yibai");    //在id为“fname”的控件中输入“yibai”
        driver.findElement(By.id("idOfButton")).click();


        Name Positioning

        driver.findElement(By.name("firstName")).sendKeys("Yiibai");
        driver.findElement(By.id("idOfButton")).click();


        Positioning the class name

        driver.findElement(By.className("Sutoomation")).click();


        Positioning the label name

        driver.findElement(By.tagName("input")).sendKeys("yibai");
        driver.findElement(By.tagName("button")).click();


        Link text positioning (all link text "Link to Yiibai")

        driver.findElement(By.linkText("Link to Yiibai")).click();


        Section link text positioning (all link text "Link to Yiibai")

        driver.findElement(By.partialLinkText("Link to")).click();  

CSS positioning also includes locating and positioning XPath
 

 

Published 80 original articles · won praise 32 · views 40000 +

Guess you like

Origin blog.csdn.net/dopdkfsds/article/details/103448540