package akash.CompleteSelenium.Practice.akash.CompleteSelenium.Practice;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class NewTab {
@Test
public void checkMe() throws Exception {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "/Users/akashaggarwal/Documents/" + "geckodriver");
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://google.com/";
driver.get(baseUrl);
driver.findElement(By.cssSelector("body")).sendKeys(Keys.COMMAND + "t");
System.out.println("hello");
}
}
package akash.CompleteSelenium.Practice.akash.CompleteSelenium.Practice;
import java.awt.Toolkit;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
public class PracticeActions {
@Test
public void testMeNow() throws Exception {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "/Users/akashaggarwal/Documents/geckodriver");
Toolkit.getDefaultToolkit().beep();
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
Thread.sleep(10000);
List <WebElement> elements = driver.findElements(By.className("anything"));
System.out.println("***************Size is "+elements.size());
WebElement e=elements.get(0);
Actions newwin = new Actions(driver);
newwin.keyDown(Keys.COMMAND).click(e).keyUp(Keys.COMMAND).build().perform();
}
}
Pls help me!! I am trying since morning !!
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL );
robot.keyPress(KeyEvent.VK_T );
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_T );
Thread.sleep(500);
**Not recommend approach it's a work around
1527775512640 geckodriver INFO geckodriver 0.20.0
1527775512649 geckodriver INFO Listening on 127.0.0.1:48003
1527775513518 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "/var/folders/l5/830bqv492h75w8mlvhy3xs3m0000gp/T/rust_mozprofile.HukmUrjC4Hoi"
2018-05-31 19:35:15.817 plugin-container[64583:763195] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x8a43, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1527775516750 Marionette INFO Listening on port 50233
2018-05-31 19:35:16.813 plugin-container[64584:763265] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x8643, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1527775516859 Marionette WARN TLS certificate errors will be ignored for this session
May 31, 2018 7:35:17 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C