zoukankan      html  css  js  c++  java
  • Driver对象的navigate方法__浏览器被操作__前进、后退、刷新、当前窗口切换到连接

    一、代码如下

    package www.gui.v2;
    
    import java.awt.AWTException;
    import java.awt.List;
    import java.awt.Robot;
    import java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import java.util.Random;
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.Select;
    
    public class LiuLanQi {
    	WebDriver driver= null;
    	Actions actions= null;
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		LiuLanQi gx= new LiuLanQi();
    		gx.init();
    
    	}
    	
    	private void init() {
    		// TODO Auto-generated method stub
    		// TODO Auto-generated method stub
    		// System.setProperty("webdriver.firefox.bin", "D:\Mozilla
    		// Firefox\firefox.exe");
    		System.setProperty("webdriver.firefox.bin", "D:\FireFox__37\firefox.exe");
    
    		this.driver = new FirefoxDriver();// 启动火狐浏览器
    
    		this.driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);// 元素等待时间
    		this.driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);// 页面加载时间
    		this.driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);// ajax请求
    		this.driver.manage().window().maximize();
    		// this.driver.get("https://www.baidu.com/");// 在浏览器中打开该网址
    		actions = new Actions(driver);
    		
    		this.driver.get("http://localhost/Agileone/");
    		this.driver.findElement(By.id("username")).sendKeys("admin");
    		this.driver.findElement(By.id("password")).sendKeys("admin");
    		this.driver.findElement(By.id("login")).click();
    		this.driver.findElement(By.partialLinkText("需求提案")).click();
    		this.driver.findElement(By.partialLinkText("缺陷跟踪")).click();
    		
    		
    		
    		this.driver.navigate().back();
    		try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}
    		this.driver.navigate().forward();
    		try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}
    		this.driver.navigate().refresh();
    		try {Thread.sleep(3000);} catch (InterruptedException e) {e.printStackTrace();}
    		this.driver.navigate().to("http://www.baidu.com");
    	
    		
    		
    	}
    	
    	
    
    }
    
  • 相关阅读:
    Delphi 窗体失踪在最上面的代码
    Delphi 目前使用delay函数功能
    Delphi Delay 延时计数的功能。 下面的方法都是思路,但是没有用在项目上
    Delphi 通过SQLite3, SQLiteTable3 操作数据库
    解决sqlite删除数据后,文件大小不变问题 转载
    delphi执行cmd命令和bat文件
    Delphi 获取sqlite中所有的表名
    delphi 获取USB口拔出和插入的状态
    深度揭密轮播插件核心代码的实现过程
    flowJS源码个人分析
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7667854.html
Copyright © 2011-2022 走看看