How to use Interface HasInputDevices class of org.openqa.selenium.interactions package

Best Selenium code snippet using org.openqa.selenium.interactions.Interface HasInputDevices

Source:DelegatingWebDriver.java Github

copy

Full Screen

1/*2 * Copyright 2019-2020 the original author or authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * https://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package org.vividus.selenium.driver;17import java.util.Collection;18import java.util.List;19import java.util.Set;20import org.openqa.selenium.By;21import org.openqa.selenium.Capabilities;22import org.openqa.selenium.HasCapabilities;23import org.openqa.selenium.JavascriptExecutor;24import org.openqa.selenium.OutputType;25import org.openqa.selenium.TakesScreenshot;26import org.openqa.selenium.WebDriver;27import org.openqa.selenium.WebDriverException;28import org.openqa.selenium.WebElement;29import org.openqa.selenium.WrapsDriver;30import org.openqa.selenium.interactions.HasInputDevices;31import org.openqa.selenium.interactions.HasTouchScreen;32import org.openqa.selenium.interactions.Interactive;33import org.openqa.selenium.interactions.Keyboard;34import org.openqa.selenium.interactions.Mouse;35import org.openqa.selenium.interactions.Sequence;36import org.openqa.selenium.interactions.TouchScreen;37public class DelegatingWebDriver implements WebDriver, JavascriptExecutor, TakesScreenshot,38 WrapsDriver, HasInputDevices, HasTouchScreen, HasCapabilities, Interactive39{40 private static final String JAVASCRIPT_NOT_SUPPORTED = "Underlying driver instance does not support executing"41 + " javascript";42 private static final String SCREENSHOTS_NOT_SUPPORTED = "Underlying driver instance does not support taking"43 + " screenshots";44 private static final String ADVANCED_INTERACTION_NOT_SUPPORTED = "Underlying driver does not implement advanced"45 + " user interactions yet.";46 private static final String DRIVER_NOT_IMPLEMENT_HAS_CAPABILITIES = "Wrapped WebDriver doesn't implement"47 + " HasCapabilities interface";48 private final WebDriver wrappedDriver;49 public DelegatingWebDriver(WebDriver webDriver)50 {51 wrappedDriver = webDriver;52 }53 @Override54 public void get(String url)55 {56 wrappedDriver.get(url);57 }58 @Override59 public String getCurrentUrl()60 {61 return wrappedDriver.getCurrentUrl();62 }63 @Override64 public String getTitle()65 {66 return wrappedDriver.getTitle();67 }68 @Override69 public List<WebElement> findElements(By by)70 {71 return wrappedDriver.findElements(by);72 }73 @Override74 public WebElement findElement(By by)75 {76 return wrappedDriver.findElement(by);77 }78 @Override79 public String getPageSource()80 {81 return wrappedDriver.getPageSource();82 }83 @Override84 public void close()85 {86 wrappedDriver.close();87 }88 @Override89 public void quit()90 {91 wrappedDriver.quit();92 }93 @Override94 public Set<String> getWindowHandles()95 {96 return wrappedDriver.getWindowHandles();97 }98 @Override99 public String getWindowHandle()100 {101 return wrappedDriver.getWindowHandle();102 }103 @Override104 public TargetLocator switchTo()105 {106 return wrappedDriver.switchTo();107 }108 @Override109 public Navigation navigate()110 {111 return wrappedDriver.navigate();112 }113 @Override114 public Options manage()115 {116 return wrappedDriver.manage();117 }118 @Override119 public WebDriver getWrappedDriver()120 {121 return wrappedDriver;122 }123 @Override124 public TouchScreen getTouch()125 {126 if (wrappedDriver instanceof HasTouchScreen)127 {128 return ((HasTouchScreen) wrappedDriver).getTouch();129 }130 throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);131 }132 @Override133 public Keyboard getKeyboard()134 {135 if (wrappedDriver instanceof HasInputDevices)136 {137 return ((HasInputDevices) wrappedDriver).getKeyboard();138 }139 throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);140 }141 @Override142 public Mouse getMouse()143 {144 if (wrappedDriver instanceof HasInputDevices)145 {146 return ((HasInputDevices) wrappedDriver).getMouse();147 }148 throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);149 }150 @Override151 public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException152 {153 if (wrappedDriver instanceof TakesScreenshot)154 {155 return ((TakesScreenshot) wrappedDriver).getScreenshotAs(target);156 }157 throw new UnsupportedOperationException(SCREENSHOTS_NOT_SUPPORTED);158 }159 @Override160 public Object executeScript(String script, Object... args)161 {162 if (wrappedDriver instanceof JavascriptExecutor)163 {164 return ((JavascriptExecutor) wrappedDriver).executeScript(script, args);165 }166 throw new UnsupportedOperationException(JAVASCRIPT_NOT_SUPPORTED);167 }168 @Override169 public Object executeAsyncScript(String script, Object... args)170 {171 if (wrappedDriver instanceof JavascriptExecutor)172 {173 return ((JavascriptExecutor) wrappedDriver).executeAsyncScript(script, args);174 }175 throw new UnsupportedOperationException(JAVASCRIPT_NOT_SUPPORTED);176 }177 @Override178 public Capabilities getCapabilities()179 {180 if (wrappedDriver instanceof HasCapabilities)181 {182 return ((HasCapabilities) wrappedDriver).getCapabilities();183 }184 throw new IllegalStateException(DRIVER_NOT_IMPLEMENT_HAS_CAPABILITIES);185 }186 @Override187 public void perform(Collection<Sequence> actions)188 {189 if (wrappedDriver instanceof Interactive)190 {191 ((Interactive) wrappedDriver).perform(actions);192 return;193 }194 throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);195 }196 @Override197 public void resetInputState()198 {199 if (wrappedDriver instanceof Interactive)200 {201 ((Interactive) wrappedDriver).resetInputState();202 return;203 }204 throw new UnsupportedOperationException(ADVANCED_INTERACTION_NOT_SUPPORTED);205 }206}...

Full Screen

Full Screen

Source:ThreadLocalWebDriver.java Github

copy

Full Screen

1package com.dev9.webtest.driver;2import com.dev9.webtest.util.SauceUtils;3import org.openqa.selenium.By;4import org.openqa.selenium.JavascriptExecutor;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.interactions.HasInputDevices;8import org.openqa.selenium.interactions.Keyboard;9import org.openqa.selenium.interactions.Mouse;10import org.openqa.selenium.remote.RemoteWebDriver;11import org.slf4j.Logger;12import org.slf4j.LoggerFactory;13import java.util.List;14import java.util.Set;15/**16 * The purpose of this class is to provide a ThreadLocal instance of a WebDriver.17 *18 * @author <a href="mailto:Justin.Graham@dev9.com">Justin Graham</a>19 * @since 8/7/1320 */21public class ThreadLocalWebDriver implements WebDriver, JavascriptExecutor, HasInputDevices {22 private static final Logger LOG = LoggerFactory.getLogger(ThreadLocalWebDriver.class);23 private static ThreadLocal<WebDriver> driver = new ThreadLocal<WebDriver>();24 private static ThreadLocal<Class> testClass = new ThreadLocal<Class>();25 private static ThreadLocal<TargetWebDriver> targetWebDriver = new ThreadLocal<TargetWebDriver>();26 private static ThreadLocal<String> jobId = new ThreadLocal<String>();27 public ThreadLocalWebDriver(Class clazz) {28 testClass.set(clazz);29 targetWebDriver.set(new TargetWebDriver(testClass.get()));30 init();31 }32 public ThreadLocalWebDriver(Class clazz, String testDescription) {33 testClass.set(clazz);34 TargetWebDriver targetDriver = new TargetWebDriver(clazz);35 if (testDescription != null && !testDescription.equals("")) {36 targetDriver.getCapabilities().setCapability("name", testDescription);37 }38 targetWebDriver.set(targetDriver);39 init();40 }41 private void init() {42 setDriver(targetWebDriver.get());43 setJobId();44 reportURL();45 }46 private void setDriver(TargetWebDriver d) {47 driver.set(d.build());48 }49 private void setJobId() {50 jobId.set(SauceUtils.getJobId(driver.get()));51 }52 public String getJobUrl() {53 return SauceUtils.getJobUrl(driver.get());54 }55 public String getJobId() {56 return jobId.get();57 }58 public boolean instanceOf(Class clazz) {59 return clazz.isAssignableFrom(driver.get().getClass());60 }61 public boolean isRemote() {62 return targetWebDriver.get().isRemote();63 }64 public Browser getBrowser() {65 return targetWebDriver.get().getBrowser();66 }67 public String getSessionId() {68 if (driver.get() instanceof RemoteWebDriver) {69 return ((RemoteWebDriver) driver.get()).getSessionId().toString();70 }71 return null;72 }73 @Override74 public void get(String s) {75 driver.get().get(s);76 }77 /* ==============================================================================78 WebDriver Interface79 ============================================================================== */80 @Override81 public String getCurrentUrl() {82 return driver.get().getCurrentUrl();83 }84 @Override85 public String getTitle() {86 return driver.get().getTitle();87 }88 @Override89 public List<WebElement> findElements(By by) {90 return driver.get().findElements(by);91 }92 @Override93 public WebElement findElement(By by) {94 return driver.get().findElement(by);95 }96 @Override97 public String getPageSource() {98 return driver.get().getPageSource();99 }100 @Override101 public void close() {102 driver.get().close();103 }104 @Override105 public void quit() {106 driver.get().quit();107 }108 @Override109 public Set<String> getWindowHandles() {110 return driver.get().getWindowHandles();111 }112 @Override113 public String getWindowHandle() {114 return driver.get().getWindowHandle();115 }116 @Override117 public TargetLocator switchTo() {118 return driver.get().switchTo();119 }120 @Override121 public Navigation navigate() {122 return driver.get().navigate();123 }124 @Override125 public Options manage() {126 return driver.get().manage();127 }128 @Override129 public Object executeScript(String s, Object... objects) {130 return ((JavascriptExecutor) driver.get()).executeScript(s, objects);131 }132 /* ==============================================================================133 JavascriptExecutor Interface134 ============================================================================== */135 @Override136 public Object executeAsyncScript(String s, Object... objects) {137 return ((JavascriptExecutor) driver.get()).executeAsyncScript(s, objects);138 }139 @Override140 public Keyboard getKeyboard() {141 return ((HasInputDevices) driver.get()).getKeyboard();142 }143 /* ==============================================================================144 HasInputDevices Interface145 ============================================================================== */146 @Override147 public Mouse getMouse() {148 return ((HasInputDevices) driver.get()).getMouse();149 }150 private void reportURL() {151 if (targetWebDriver.get().isRemote()) {152 LOG.info("Remote job url: {}", getJobUrl());153 }154 }155}...

Full Screen

Full Screen

Source:MouseActions.java Github

copy

Full Screen

1package org.fluentlenium.core.action;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.interactions.Coordinates;4import org.openqa.selenium.interactions.HasInputDevices;5import org.openqa.selenium.interactions.Mouse;6/**7 * Execute actions with the mouse.8 */9public class MouseActions {10 private final WebDriver driver;11 /**12 * Creates a new mouse actions.13 *14 * @param driver driver15 */16 public MouseActions(WebDriver driver) {17 this.driver = driver;18 }19 /**20 * Get the actions object.21 *22 * @return actions object23 */24 protected org.openqa.selenium.interactions.Actions actions() {25 return new org.openqa.selenium.interactions.Actions(driver);26 }27 /**28 * Basic mouse operations29 *30 * @return low level interface to control the mouse31 * @deprecated Use the following mapping for updating your code:32 * <p>33 * {@link Mouse#click(Coordinates)} to {@link MouseElementActions#click()}34 * <p>35 * {@link Mouse#doubleClick(Coordinates)} to {@link MouseElementActions#doubleClick()}36 * <p>37 * {@link Mouse#mouseDown(Coordinates)} to {@link MouseElementActions#moveToElement()}38 * then {@link MouseElementActions#clickAndHold()}39 * <p>40 * {@link Mouse#mouseUp(Coordinates)} to {@link MouseElementActions#release()}41 * <p>42 * {@link Mouse#mouseMove(Coordinates)} to {@link MouseElementActions#moveToElement()}43 * <p>44 * {@link Mouse#mouseMove(Coordinates, long, long)} to {@link MouseElementActions#moveToElement(int, int)}45 * <p>46 * {@link Mouse#contextClick(Coordinates)} to {@link MouseElementActions#contextClick()}47 */48 @Deprecated49 public Mouse basic() {50 return ((HasInputDevices) driver).getMouse();51 }52 /**53 * Clicks (without releasing) at the current mouse location.54 *55 * @return this object reference to chain calls56 * @see org.openqa.selenium.interactions.Actions#clickAndHold()57 */58 public MouseActions clickAndHold() {59 actions().clickAndHold().perform();60 return this;61 }62 /**63 * Releases the depressed left mouse button at the current mouse location.64 *65 * @return this object reference to chain calls66 * @see org.openqa.selenium.interactions.Actions#release()67 */68 public MouseActions release() {69 actions().release().perform();70 return this;71 }72 /**73 * Clicks at the current mouse location. Useful when combined with74 *75 * @return this object reference to chain calls76 * @see org.openqa.selenium.interactions.Actions#click()77 */78 public MouseActions click() {79 actions().click().perform();80 return this;81 }82 /**83 * Performs a double-click at the current mouse location.84 *85 * @return this object reference to chain calls86 */87 public MouseActions doubleClick() {88 actions().doubleClick().perform();89 return this;90 }91 /**92 * Performs a context-click at the current mouse location.93 *94 * @return this object reference to chain calls95 * @see org.openqa.selenium.interactions.Actions#contextClick()96 */97 public MouseActions contextClick() {98 actions().contextClick().perform();99 return this;100 }101 /**102 * Moves the mouse from its current position (or 0,0) by the given offset. If the coordinates103 * provided are outside the viewport (the mouse will end up outside the browser window) then104 * the viewport is scrolled to match.105 * @param xOffset horizontal offset. A negative value means moving the mouse left.106 * @param yOffset vertical offset. A negative value means moving the mouse up.107 * @return this object reference to chain calls108 * @see org.openqa.selenium.interactions.Actions#moveByOffset(int, int)109 */110 public MouseActions moveByOffset(int xOffset, int yOffset) {111 actions().moveByOffset(xOffset, yOffset).perform();112 return this;113 }114}...

Full Screen

Full Screen

Source:KeyboardActions.java Github

copy

Full Screen

1package org.fluentlenium.core.action;2import org.openqa.selenium.Keys;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.interactions.HasInputDevices;6import org.openqa.selenium.interactions.Keyboard;7/**8 * Execute actions with the keyboard.9 */10public class KeyboardActions {11 private final WebDriver driver;12 /**13 * Creates a new object to execute actions with the keyboard, using given selenium driver.14 *15 * @param driver selenium driver16 */17 public KeyboardActions(WebDriver driver) {18 this.driver = driver;19 }20 /**21 * Get selenium interactions actions.22 *23 * @return selenium actions24 */25 protected org.openqa.selenium.interactions.Actions actions() {26 return new org.openqa.selenium.interactions.Actions(driver);27 }28 /**29 * Basic keyboard operations30 *31 * @return low level interface to control the keyboard32 * @deprecated Use {@link KeyboardActions#keyDown(Keys)} and {@link KeyboardActions#keyUp(Keys)}33 * and {@link KeyboardActions#sendKeys(CharSequence...)} instead34 */35 @Deprecated36 public Keyboard basic() {37 return ((HasInputDevices) driver).getKeyboard();38 }39 /**40 * Performs a modifier key press. Does not release the modifier key - subsequent interactions41 * may assume it's kept pressed.42 * Note that the modifier key is <b>never</b> released implicitly - either43 * <i>keyUp(theKey)</i> or <i>sendKeys(Keys.NULL)</i>44 * must be called to release the modifier.45 *46 * @param theKey Either {@link Keys#SHIFT}, {@link Keys#ALT} or {@link Keys#CONTROL}. If the47 * provided key is none of those, {@link IllegalArgumentException} is thrown.48 * @return this object reference to chain calls49 * @see org.openqa.selenium.interactions.Actions#keyDown(CharSequence)50 */51 public KeyboardActions keyDown(Keys theKey) {52 actions().keyDown(theKey).perform();53 return this;54 }55 /**56 * Performs a modifier key release. Releasing a non-depressed modifier key will yield undefined57 * behaviour.58 *59 * @param theKey Either {@link Keys#SHIFT}, {@link Keys#ALT} or {@link Keys#CONTROL}.60 * @return this object reference to chain calls61 * @see org.openqa.selenium.interactions.Actions#keyUp(CharSequence)62 */63 public KeyboardActions keyUp(Keys theKey) {64 actions().keyUp(theKey).perform();65 return this;66 }67 /**68 * Sends keys to the active element. This differs from calling69 * {@link WebElement#sendKeys(CharSequence...)} on the active element in two ways:70 * <ul>71 * <li>The modifier keys included in this call are not released.</li>72 * <li>There is no attempt to re-focus the element - so sendKeys(Keys.TAB) for switching73 * elements should work. </li>74 * </ul>75 *76 * @param keysToSend The keys.77 * @return A self reference.78 * @see org.openqa.selenium.interactions.Actions#sendKeys(CharSequence...)79 */80 public KeyboardActions sendKeys(CharSequence... keysToSend) {81 actions().sendKeys(keysToSend).perform();82 return this;83 }84}...

Full Screen

Full Screen

Source:Browser.java Github

copy

Full Screen

1package com.algocrafts.selenium;2import org.openqa.selenium.*;3import org.openqa.selenium.interactions.HasInputDevices;4import org.openqa.selenium.interactions.Keyboard;5import org.openqa.selenium.interactions.Mouse;6import java.util.List;7import java.util.Set;8public interface Browser<T extends WebDriver> extends Actionable<T>,9 SearchScope<Browser<T>>,10 WebDriver,11 HasInputDevices, JavascriptExecutor, HasCapabilities {12 CachedWebDriverSupplier<T> getSupplier();13 @Override14 default void onTimeout() {15 if (logger.isDebugEnabled()) {16 save(this.getTitle());17 }18 }19 @Override20 default T init() {21 return getSupplier().init();22 }23 @Deprecated24 @Override25 default Element findElement(By by) {26 return new ElementFinder(by).locate(get());27 }28 @Deprecated29 @Override30 default List<WebElement> findElements(By by) {31 return new ElementsFinder(by).locate(get());32 }33 @Override34 default void get(String url) {35 get().get(url);36 }37 @Override38 default String getCurrentUrl() {39 return get().getCurrentUrl();40 }41 @Override42 default String getTitle() {43 return get().getTitle();44 }45 @Override46 default String getPageSource() {47 return get().getPageSource();48 }49 @Override50 default Set<String> getWindowHandles() {51 return get().getWindowHandles();52 }53 @Override54 default String getWindowHandle() {55 return get().getWindowHandle();56 }57 @Override58 default TargetLocator switchTo() {59 return get().switchTo();60 }61 @Override62 default Navigation navigate() {63 return get().navigate();64 }65 @Override66 default Options manage() {67 return get().manage();68 }69 @Override70 default void close() {71 get().close();72 }73 @Override74 default void quit() {75 store.valueOf(this).quit();76 store.remove(this);77 }78 @Override79 default Keyboard getKeyboard() {80 HasInputDevices t = (HasInputDevices) get();81 return t.getKeyboard();82 }83 @Override84 default Mouse getMouse() {85 HasInputDevices t = (HasInputDevices) get();86 return t.getMouse();87 }88 @Override89 default Capabilities getCapabilities() {90 HasCapabilities hasCapabilities = (HasCapabilities) get();91 return hasCapabilities.getCapabilities();92 }93 @Override94 default Object executeScript(String script, Object... args) {95 JavascriptExecutor javascriptExecutor = (JavascriptExecutor) get();96 return javascriptExecutor.executeScript(script, args);97 }98 @Override99 default Object executeAsyncScript(String script, Object... args) {100 JavascriptExecutor javascriptExecutor = (JavascriptExecutor) get();101 return javascriptExecutor.executeAsyncScript(script, args);102 }103}...

Full Screen

Full Screen

Source:Mouse_interfaceClass.java Github

copy

Full Screen

1package keyboard_mouse_and_touch_interfaces;23import java.util.concurrent.TimeUnit;4import org.openqa.selenium.By;5import org.openqa.selenium.WebDriver;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.chrome.ChromeDriver;8import org.openqa.selenium.interactions.HasInputDevices;9import org.openqa.selenium.interactions.Locatable;10import org.openqa.selenium.interactions.Mouse;11import org.openqa.selenium.interactions.internal.Coordinates;1213public class Mouse_interfaceClass 14{1516 public static void main(String[] args) 17 {18 19 WebDriver driver=new ChromeDriver();20 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);21 driver.get("https://www.amazon.in/");22 driver.manage().window().maximize();23 24 //Enable mouse interface on automation browser25 Mouse mouse=((HasInputDevices)driver).getMouse();26 27 //Identify location before hover28 WebElement Category=driver.findElement(By.xpath("//span[contains(.,'Category')]"));29 //Get elemnet Coordinates30 Coordinates Obj_Co=((Locatable)Category).getCoordinates();31 //Peform mouse hover action on location32 mouse.mouseMove(Obj_Co);33 34 35 //Identify location36 WebElement Mobiles=driver.findElement(By.xpath("//span[text()='Mobiles, Computers']"));37 //hover on location38 mouse.mouseMove(((Locatable)Mobiles).getCoordinates());39 40 //Target location41 WebElement Laptops=driver.findElement(By.xpath("//span[contains(.,'Laptops')]"));42 mouse.click(((Locatable)Laptops).getCoordinates());43 }4445} ...

Full Screen

Full Screen

Source:Mouse_Hover.java Github

copy

Full Screen

1package mouse_Actions;23import org.openqa.selenium.By;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.chrome.ChromeDriver;7import org.openqa.selenium.interactions.HasInputDevices;8import org.openqa.selenium.interactions.Locatable;9import org.openqa.selenium.interactions.Mouse;10import org.openqa.selenium.interactions.internal.Coordinates;1112public class Mouse_Hover 13{1415 public static void main(String[] args) throws Exception 16 {17 WebDriver driver=new ChromeDriver();18 driver.get("https://www.hdfcbank.com/");19 driver.manage().window().maximize();20 21 22 //Enable MouseInterface class controls on browser23 Mouse mouse=((HasInputDevices)driver).getMouse();24 25 //Identify Target26 WebElement Products=driver.findElement(By.linkText("Products"));27 //Get element coordinate using locatable class28 Coordinates Products_Co=((Locatable)Products).getCoordinates();29 mouse.mouseMove(Products_Co);30 Thread.sleep(5000);31 32 //Identify Target33 WebElement Loan=driver.findElement(By.linkText("Loans"));34 //Get element coordinate using locatable class35 Coordinates Loan_Co=((Locatable)Loan).getCoordinates(); 36 mouse.mouseMove(Loan_Co);37 Thread.sleep(5000);38 39 WebElement Personal_Loan=driver.findElement(By.linkText("Personal Loan"));40 Coordinates Personal_Loan_co=((Locatable)Personal_Loan).getCoordinates();41 42 mouse.click(Personal_Loan_co);43 44 driver.close();4546 }4748} ...

Full Screen

Full Screen

Source:Interaction.java Github

copy

Full Screen

1package org.primitive.webdriverencapsulations.components.bydefault;23import org.openqa.selenium.WebDriver;4import org.openqa.selenium.interactions.HasInputDevices;5import org.openqa.selenium.interactions.HasTouchScreen;67public abstract class Interaction extends WebdriverInterfaceImplementor implements HasInputDevices, HasTouchScreen {89 public Interaction(WebDriver driver) {10 super(driver);11 delegate = this.driver;12 }13} ...

Full Screen

Full Screen

Interface HasInputDevices

Using AI Code Generation

copy

Full Screen

1package com.selenium4beginners.java.touchactions;2import org.openqa.selenium.By;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.interactions.HasInputDevices;5import org.openqa.selenium.interactions.HasTouchScreen;6import org.openqa.selenium.interactions.MultiTouchAction;7import org.openqa.selenium.interactions.TouchAction;8import org.openqa.selenium.interactions.TouchActions;9import org.openqa.selenium.interactions.TouchScreen;10import org.openqa.selenium.remote.RemoteTouchScreen;11import org.openqa.selenium.support.ui.ExpectedConditions;12import org.openqa.selenium.support.ui.WebDriverWait;13import com.selenium4beginners.java.common.DriverFactory;14public class TouchActionsExample extends DriverFactory {15 public static void main(String[] args) {16 driver.findElement(By.id("btn_basic_example")).click();17 WebDriverWait wait = new WebDriverWait(driver, 20);18 TouchScreen touchScreen = ((HasTouchScreen) driver).getTouch();19 TouchActions touchActions = new TouchActions(touchScreen);20 touchActions.singleTap(datePickersLink).perform();21 touchActions.singleTap(bootstrapDatePickersLink).perform();22 dateTextBox.click();

Full Screen

Full Screen

Interface HasInputDevices

Using AI Code Generation

copy

Full Screen

1package com.packt.webdriver.chapter2;2import java.util.List;3import org.openqa.selenium.By;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.firefox.FirefoxDriver;7import org.openqa.selenium.interactions.Actions;8import org.openqa.selenium.interactions.HasInputDevices;9public class MouseOver {10 public static void main(String[] args){11 WebDriver driver = new FirefoxDriver();12 Actions builder = new Actions(driver);13 WebElement element = driver.findElement(By.id("menu-item-1978"));14 builder.moveToElement(element).build().perform();15 System.out.println("Number of submenus in the menu are "+subElement.size());16 for(WebElement we:subElement){17 System.out.println(we.getText());18 }19 }20}21package com.packt.webdriver.chapter2;22import java.util.List;23import org.openqa.selenium.By;24import org.openqa.selenium.WebDriver;25import org.openqa.selenium.WebElement;26import org.openqa.selenium.firefox.FirefoxDriver;27import org.openqa.selenium.interactions.Actions;28import org.openqa.selenium.interactions.HasTouchScreen;29import org.openqa.selenium.interactions.TouchScreen;30import org.openqa.selenium.interactions.touch.TouchActions;31public class TouchExample {32 public static void main(String[] args){33 WebDriver driver = new FirefoxDriver();34 TouchScreen touchScreen = ((HasTouchScreen)driver).getTouch();35 TouchActions touchAction = new TouchActions(touchScreen);36 WebElement element = driver.findElement(By.id("menu-item-1978"));37 touchAction.singleTap(element).perform();38 System.out.println("Number of submenus in the menu are "+subElement.size());39 for(WebElement we:subElement){40 System.out.println(we.getText());41 }42 }43}

Full Screen

Full Screen

Interface HasInputDevices

Using AI Code Generation

copy

Full Screen

11. import org.openqa.selenium.interactions.HasInputDevices;22. import org.openqa.selenium.interactions.Keyboard;33. import org.openqa.selenium.interactions.Mouse;44. import org.openqa.selenium.interactions.Actions;55. HasInputDevices hasInputDevices = (HasInputDevices) driver;66. Mouse mouse = hasInputDevices.getMouse();77. Keyboard keyboard = hasInputDevices.getKeyboard();88. Actions actions = new Actions(driver);99. actions.clickAndHold(element);1010. actions.keyDown(Keys.CONTROL);1111. actions.sendKeys("a");1212. actions.keyUp(Keys.CONTROL);1313. actions.sendKeys("t");1414. actions.build().perform();1515. actions.clickAndHold(element);1616. actions.sendKeys("a");1717. actions.sendKeys("t");1818. actions.build().perform();1919. mouse.mouseDown(element);2020. keyboard.sendKeys("a");2121. keyboard.sendKeys("t");2222. mouse.mouseUp(element);2323. mouse.mouseDown(element);2424. keyboard.sendKeys("a");2525. keyboard.sendKeys("t");2626. mouse.mouseUp(element);2727. mouse.mouseDown(element);2828. keyboard.sendKeys("a");2929. keyboard.sendKeys("t");3030. mouse.mouseUp(element);3131. mouse.mouseDown(element);3232. keyboard.sendKeys("a");3333. keyboard.sendKeys("t");3434. mouse.mouseUp(element);3535. mouse.mouseDown(element);3636. keyboard.sendKeys("a");3737. keyboard.sendKeys("t");3838. mouse.mouseUp(element);3939. mouse.mouseDown(element);4040. keyboard.sendKeys("a");4141. keyboard.sendKeys("t");4242. mouse.mouseUp(element);4343. mouse.mouseDown(element);4444. keyboard.sendKeys("a");4545. keyboard.sendKeys("t");4646. mouse.mouseUp(element);4747. mouse.mouseDown(element);4848. keyboard.sendKeys("a");4949. keyboard.sendKeys("t");5050. mouse.mouseUp(element);5151. mouse.mouseDown(element);5252. keyboard.sendKeys("a");5353. keyboard.sendKeys("t");5454. mouse.mouseUp(element);5555. mouse.mouseDown(element);5656. keyboard.sendKeys("a");5757. keyboard.sendKeys("t");5858. mouse.mouseUp(element);5959. mouse.mouseDown(element);6060. keyboard.sendKeys("a");6161. keyboard.sendKeys("t");6262. mouse.mouseUp(element);6363. mouse.mouseDown(element);6464. keyboard.sendKeys("a");6565. keyboard.sendKeys("t");

Full Screen

Full Screen

Interface HasInputDevices

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.interactions.HasInputDevices;2import org.openqa.selenium.interactions.Keyboard;3import org.openqa.selenium.interactions.Mouse;4import org.openqa.selenium.interactions.Action;5import org.openqa.selenium.interactions.Actions;6import org.openqa.selenium.interactions.Coordinates;7import org.openqa.selenium.interactions.Locatable;8import org.openqa.selenium.interactions.PointerInput;9import org.openqa.selenium.interactions.PointerInput.Kind;10import org.openqa.selenium.interactions.PointerInput.MouseButton;11import org.openqa.selenium.interactions.Sequence;12import org.openqa.selenium.interactions.TouchScreen;13import org.openqa.selenium.interactions.internal.Coordinates;14import org.openqa.selenium.interactions.internal.Locatable;15import org.openqa.selenium.interactions.internal.MouseAction;16import org.openqa.selenium.interactions.internal.TouchAction;17import org.openqa.selenium.interactions.internal.TouchScreenAction;18import org.openqa.selenium.internal.Locatable;19import org.openqa.selenium.remote.RemoteTouchScreen;20import org.openqa.selenium.remote.RemoteWebElement;21import org.openqa.selenium.remote.RemoteWebDriver;22import org.openqa.selenium.remote.RemoteWebElement;23import org.openqa.selenium.remote.internal.WebElementToJsonConverter;24import org.openqa.selenium.support.ui.WebDriverWait;25import org.openqa.selenium.support.ui.ExpectedConditions;26import org.openqa.selenium.support.ui.ExpectedCondition;27import org.openqa.selenium.support.ui.Select;28import org.openqa.selenium.support.ui.FluentWait;29import org.openqa.selenium.support.ui.Wait;30import org.openqa.selenium.support.ui.Sleeper;31import org.openqa.selenium.support.ui.SystemClock;32import org.openqa.selenium.support.ui.Clock;33import org.openqa.selenium.support.ui.FluentWait;34import org.openqa.selenium.support.ui.Wait;35import org.openqa.selenium.support.ui.SystemClock;36import org.openqa.selenium.support.ui.Clock;37import org.openqa.selenium.support.ui.FluentWait;38import org.openqa.selenium.support.ui.Wait;39import org.openqa.selenium.support.ui.SystemClock;40import org.openqa.selenium.support.ui.Clock;41import org.openqa.selenium.support.ui.FluentWait;42import org.openqa.selenium.support.ui.Wait;43import org.openqa.selenium.support.ui.SystemClock;44import org.openqa.selenium.support.ui.Clock;45import org.openqa.selenium.support.ui.FluentWait;46import org.openqa.selenium.support.ui.Wait;47import org.openqa.selenium.support.ui.SystemClock;48import org.openqa.selenium.support.ui.Clock;49import org.openqa.selenium.support.ui.FluentWait;50import org.openqa.selenium.support.ui.Wait;51import org.openqa.selenium.support.ui.SystemClock;52import org.openqa.selenium.support.ui.Clock;53import org.openqa.selenium.support.ui.FluentWait;

Full Screen

Full Screen

Interface HasInputDevices

Using AI Code Generation

copy

Full Screen

1interface HasInputDevices {2 Keyboard getKeyboard();3 Mouse getMouse();4}5class Keyboard {6 void sendKeys(CharSequence... keysToSend);7 void pressKey(CharSequence keyToPress);8 void releaseKey(CharSequence keyToRelease);9}10class Mouse {11 void click(Coordinates where);12 void doubleClick(Coordinates where);13 void mouseDown(Coordinates where);14 void mouseUp(Coordinates where);15 void mouseMove(Coordinates where);16 void mouseMove(Coordinates where, long xOffset, long yOffset);17 void contextClick(Coordinates where);18}19class Coordinates {20 Point onScreen();21 Point inViewPort();22 Point onPage();

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in Interface-HasInputDevices

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful