package rjcs; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; import org.openqa.selenium.interactions.Actions; import org.apache.commons.io.FileUtils; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.testng.annotations.Test; import org.openqa.selenium.*; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.openqa.selenium.OutputType; import com.thoughtworks.selenium.SeleneseTestNgHelper; public class ckqh { public static void main(String[] args) { System.setProperty ( "webdriver.firefox.bin", "C: \\ Program Files (the x86) \\ \\ firefox.exe the Mozilla Firefox"); // set the installation path Firefox, preventing system can not find FirefoxDriver Driver = new new FirefoxDriver (); // initialize FireFox browser instance, and open the browser try { . driver.manage () window () the Maximize ();. // maximize the window Thread.sleep ( 5000 ); . driver.manage () window () the Maximize ();. // maximize the window Thread.sleep ( 5000 ); driver.get ( "https://www.baidu.com"); // open a Web site, a method of the Thread.sleep ( 5000 ); Actions action = new Actions(driver); Thread.sleep(5000); action.keyDown (Keys.CONTROL) .sendKeys ( "t") keyUp (Keys.CONTROL) .perform ();. // ctr + t shortcut to open a new tab driver.get("https://www.ifeng.com"); Thread.sleep(10000); }catch (Exception e) { e.printStackTrace (); }finally { driver.quit(); } } }
+ java + selenium-- keyboard shortcut ctrl + t-- open a new tab
Guess you like
Origin www.cnblogs.com/xiaobaibailongma/p/12216003.html
Ranking