• 自动化测试1_java+appium初探


    第一个自动化的例子  

      首先创建了java的项目、包、类之后,右键项目名称,点击properties,选择java build path,把selenium添加到项目里面。

      从selenium的官网中复制下来一个例子,跑一边简单的流程。大体的代码如下,我把官网的代码稍微修改了一下,然后做了简单的注释。

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    public class FirstAuto {
        public static void main(String[] args){
                    //设置driver路径
                    System.setProperty("webdriver.chrome.driver", "E:\chromedriver.exe");
                    //打开浏览器
                    WebDriver driver = new ChromeDriver();
    
    
                    //打开网址
                    driver.get("http://www.baidu.com");
    
                    //ͨ定位到输入框
                    WebElement element = driver.findElement(By.name("wd"));
    
                    //输入框
                    element.sendKeys("测试!");
    
                    //提交搜索
                    element.submit();
    
                    //获取网站的标题,然后打印出来
                    System.out.println("Page title is: " + driver.getTitle());
                    
                    //校验标题
                    System.out.println("Page title is: " + driver.getTitle());
    //加个等待,然后关闭浏览器
    try { Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Close the browser driver.quit(); } }
  • 相关阅读:
    celery 转自:https://www.cnblogs.com/pyedu/p/12461819.html
    k8s 学习笔记
    linux 学习笔记3
    yaml initc
    vi 块操作
    curl
    知名IT互联网公司
    ajax 上传文件给webapi(带basic认证)
    C# 后台请求api
    mvc 母版页保持不刷新
  • 原文地址:https://www.cnblogs.com/qq764552199/p/8081600.html
Copyright © 2020-2023  润新知