As you lot know, Selenium webdriver Is really big projection which supports many dissimilar languages to exercise testify cases in addition to execute them In dissimilar browsers. It back upwardly keyboard in addition to mouse events really effectively using Advanced User Interaction API. I bring listed Advanced User Interaction API
tutorial links On THIS PAGE. Page Zoom In/Out Is i of the tricky activeness in addition to nosotros tin exercise It using advanced user Interaction API.
How to perform Zoom In/Out?
We volition usage webdriver advanced user Interaction API to perform this operation. We tin perform page zoom activeness using Method sendKeys(WebElement element, java.lang.CharSequence... keysToSend). Here element Is webelement which volition have keystrokes in addition to CharSequence Is sequence of characters to post on element.
Bellow given instance volition expain you lot to a greater extent than how to zoom In/out/default degree of page.
package Testing_Pack; import java.util.concurrent.TimeUnit; 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.BeforeTest; import org.testng.annotations.Test; world cast ZoomBrowser { WebDriver driver; @BeforeTest world void setup() throws Exception { driver = novel FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("http://google.com/"); } @Test world void getScrollStatus(){ //Call zooming functions to zoom inwards in addition to out page. zoomIn(); zoomOut(); zoomOut(); set100(); } world void zoomIn(){ //To zoom In page iv fourth dimension using CTRL in addition to + keys. for(int i=0; i<4; i++){ driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD)); } } world void zoomOut(){ //To zoom out page iv fourth dimension using CTRL in addition to - keys. for(int i=0; i<4; i++){ driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT)); } } world void set100(){ //To ready browser to default zoom degree 100% driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0")); } }
When you lot run inwards a higher house example, 1st It volition zoom In page iv times hence It volition zoom out page 8 fourth dimension in addition to hence It volition ready browser at default 100% zoom level.
http://www.software-testing-tutorials-automation.com/