1.
Maximize Firefox browser window using selenium
webdriver
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
3. Get current web page URL
System.out.println(driver.getCurrentUrl());
4. Navigate Back | Forward & Page refresh
Navigate Back
Webdriver driver = new FirefoxDriver();
driver.navigate().back();
5. Highlighting Elements
WebElement element1 = driver.findElement(By.className("Value"));
WebElement element2 = driver.findElement(By.id("Value"));
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].setAttribute('style', arguments[1]);", element1, "color: blue; border: 2px solid blue;");
6. Double-click WebElement
action.perform();
7. Delete All Cookies
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
2. Customize
browser window size
driver.manage().window().setSize(new
Dimension(320, 480));3. Get current web page URL
System.out.println(driver.getCurrentUrl());
4. Navigate Back | Forward & Page refresh
Navigate Back
Webdriver driver = new FirefoxDriver();
driver.navigate().back();
(or)
Actions actions = new
Actions(driver);
actions.sendKeys(Keys.BACK_SPACE).perform();
Navigate Forward
driver.navigate().forward();
Page Refresh
driver.navigate().refresh();
(or)
Actions actions = new
Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();5. Highlighting Elements
WebElement element1 = driver.findElement(By.className("Value"));
WebElement element2 = driver.findElement(By.id("Value"));
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].setAttribute('style', arguments[1]);", element1, "color: blue; border: 2px solid blue;");
jse.executeScript("arguments[0].setAttribute('style',
arguments[1]);", element2, "color: yellow; border: 0px solid
red;");
6. Double-click WebElement
Actions action = new Actions(driver);
action.doubleClick(driver.findElement(By.id("Value")));
action.perform();
7. Delete All Cookies
driver.manage().deleteAllCookies();
No comments:
Post a Comment