Let's chat:
My first job after graduation is very important. I graduated from 985 in June 2015 and started working in July. Due to my confusion about my career and the consequences of choosing an offer wrong (it is also wrong to think too much), I am not engaged in the automation testing work that I have always been willing to do. I want to change my job this year, and I still want to do automation testing work. However, there is currently an offer that is not a test (injury!), and there is another test offer waiting for the results. I guess I will be notified in the next two days (I hope I can be hired!!). Using my experience, I would like to remind everyone that before graduation, you must think about the direction you want to engage in, and when choosing an offer, you must choose a large company that is beneficial to your development without hesitation~
Now organize the automatic opening of the web page that implements the Java and selenium frameworks
1. Preparation phase
Install eclipse; and load the relevant jar packages of selenium into eclipse:
2. Java code implementation:
</pre><pre name="code">package javaSelenium_Test;import org.openqa.selenium.By;//Open the firefox browser's http://baidu.com URL import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;//Import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.server.browserlaunchers.Sleeper;public class Case1 { public static void main(String[] args){// WebDriver driver = new FirefoxDriver(); System.setProperty("webdriver.firefox.bin", "C://Program Files (x86)//Mozilla Firefox//firefox.exe"); WebDriver driver = new FirefoxDriver(); driver.get("http://baidu.com"); WebElement input = driver.findElement(By.xpath(".//*[@id='kw']")); CharSequence[] cs = new CharSequence[1]; cs[0]="Anjuke"; input.sendKeys(cs); WebElement btn = driver.findElement(By.xpath(".//*[@id='su']")); btn.click();//WebElement btn1 = driver.findElement(By.xpath(".//*[@id='w-75cn8k']/div/h2/a[1]")); //btn1.click(); System.out.println("Page title is:"+driver.getTitle()); //Sleep(2000); driver.close(); }}The above method to automatically open the page in java+selenium is the entire content shared by the editor. I hope it can give you a reference and I hope you can support Wulin.com more.