This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
driver.findElement(By.cssSelector("body")).sendKeys(Keys.COMMAND + "t"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void openNewTab() { | |
String osName = System.getProperty("os.name").toLowerCase(); | |
if (osName.contains("win")) { | |
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "t"); | |
} else { | |
driver.findElement(By.cssSelector("body")).sendKeys(Keys.COMMAND + "t"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((JavascriptExecutor) driver).executeScript("window.open('','_blank');"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((JavascriptExecutor) driver).executeScript("window.open('http://accounts.google.com/','_blank');"); | |
//here URL is - http://accounts.google.com/ send as parameter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
public class FirstScript { | |
public static void main(String args[]){ | |
WebDriver driver = new FirefoxDriver(); | |
driver.get("http://qaperspective.blogspot.in/p/step-by-step-selenium-guide-this.html"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
/** | |
* Created by Amol Chavan on 9/19/2016. | |
*/ | |
public class PrivateBrowsing { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.firefox.FirefoxProfile; | |
/** | |
* Created by Amol Chavan on 9/19/2016. | |
*/ | |
public class PrivateBrowsing { | |
public static void main(String args[]){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.ie.InternetExplorerDriver; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
/** | |
* Created by Amol Chavan on 9/19/2016. | |
*/ | |
public class PrivateBrowsing { | |
public static void main(String args[]){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logs logs = driver.manage().logs(); | |
LogEntries logEntries = logs.get(LogType.BROWSER); | |
for(LogEntry logEntry :logEntries) | |
{ | |
if (logEntry.getMessage().toLowerCase().contains("error")) { | |
System.out.println("Error Message in Console:"+logEntry.getMessage()); | |
} else if (logEntry.getMessage().toLowerCase().contains("warning")){ | |
System.out.println("Warning Message in Console:"+logEntry.getMessage()); | |
}else{ | |
System.out.println("Information Message in Console:"+logEntry.getMessage()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tests; | |
import org.openqa.selenium.JavascriptExecutor; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.logging.LogEntries; | |
import org.openqa.selenium.logging.LogEntry; | |
import org.openqa.selenium.logging.LogType; | |
import org.openqa.selenium.logging.Logs; | |
import org.openqa.selenium.support.ui.WebDriverWait; |