Today revisit the two, the operation of the browser window, and access to the current page URL. The old rules to create a new class of it in their own eclipse automation engineering. Let's continue the line and code.
package cn.autotest;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class WebDriverApi3 {
public WebDriver wd;
String baiduurl = "https://www.baidu.com"; // To access the website
// get the first title of the property page and get the page source code
@Test(priority=1)
public void operationBr () throws InterruptedException{
// declare a Point object, wherein two representatives from the 200 abscissa and ordinate
Point point = new Point(200, 200);
// declare Dimension object 500 represents the length and width of the browser
Dimension dimension = new Dimension(500,500);
this.beforeTest (); // Call method enabled Firefox browser
wd.get (baiduurl); // access Baidu
Thread.sleep(2000);
// set the coordinate use setPostion browser on the screen, Ponit
wd.manage().window().setPosition(point);
// To see clearly, pause
Thread.sleep(3000);
// set the window size using setSize 500 units long and the frame
wd.manage().window().setSize(dimension);
// continue to wait about
Thread.sleep(3000);
// print out on both, with getPosition () and getSize ()
System.out.print(wd.manage().window().getPosition());
System.out.print(wd.manage().window().getSize());
After // print to see if the argument is not that we set, if it proves successful.
// to maximize browser
wd.manage().window().maximize();
Thread.sleep(2000);
wd.close (); // every time you close your browser
}
// then presents a method to obtain the URL
@Test(priority=2)
public void getUrl() throws InterruptedException{
// first open the browser
this.beforeTest();
wd.get(baiduurl);
Thread.sleep(2000);
// Get the URL of the current page
String PAGEURL wd.getCurrentUrl = ();
//print it out
System.out.print (PAGEURL);
// to be asserted
Assert.assertEquals(baiduurl+"/", pageurl);
// Close the browser
wd.close();
}
public void beforeTest(){
// Start Firefox
System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox\\firefox.exe");
wd = new FirefoxDriver();
}
}
And then do what is not written in accordance with our first vertical and horizontal coordinates 200, and then set the execution window 500, and print out a successful website URL
No micro-channel public concern king brother automated test or scan code