List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:io.openvidu.test.OpenViduClientBrowserTest.java
License:Apache License
public void joinToRoom(int pageIndex, String userName, String roomName) { Browser userBrowser = getPage(getBrowserKey(pageIndex)).getBrowser(); WebElement nameInput = findElement(userName, userBrowser, "name"); nameInput.clear(); nameInput.sendKeys(userName);/* ww w .ja v a 2 s . c om*/ WebElement roomInput = findElement(userName, userBrowser, "roomName"); roomInput.clear(); roomInput.sendKeys(roomName); findElement(userName, userBrowser, "joinBtn").submit(); log.debug("Clicked on 'joinBtn' in {}", userName); }
From source file:io.selendroid.demo.nativeui.UserRegistrationTest.java
License:Apache License
private void registerUser(UserDO user) throws Exception { driver.get("and-activity://io.selendroid.testapp.RegisterUserActivity"); WebElement username = driver.findElement(By.id("inputUsername")); username.sendKeys(user.username);//from w w w .j a va 2 s . com driver.findElement(By.name("email of the customer")).sendKeys(user.email); driver.findElement(By.id("inputPassword")).sendKeys(user.password); WebElement nameInput = driver.findElement(By.xpath("//EditText[@id='inputName']")); Assert.assertEquals(nameInput.getText(), "Mr. Burns"); nameInput.clear(); nameInput.sendKeys(user.name); driver.findElement(By.tagName("Spinner")).click(); driver.findElement(By.linkText(user.programmingLanguage)).click(); driver.findElement(By.className("android.widget.CheckBox")).click(); driver.findElement(By.linkText("Register User (verify)")).click(); Assert.assertEquals(driver.getCurrentUrl(), "and-activity://VerifyUserActivity"); }
From source file:io.selendroid.driver.NavigationTests.java
License:Apache License
@Test() public void shouldNotDoRefreshInWebviewMode() throws Exception { openWebdriverTestPage(HtmlTestData.SAY_HELLO_DEMO); WebElement inputField = driver().findElement(By.id("name_input")); inputField.clear(); inputField.sendKeys("a text"); Assert.assertEquals("a text", inputField.getAttribute("value")); driver().navigate().refresh();/*from ww w . j a v a 2 s. co m*/ inputField = driver().findElement(By.id("name_input")); Assert.assertEquals("Enter your name here!", inputField.getAttribute("value")); }
From source file:io.selendroid.nativetests.CommandConfigurationTest.java
License:Apache License
@Test public void shouldSetJapaneseTextIntoWebInputField() { openWebdriverTestPage(HtmlTestData.SAY_HELLO_DEMO); Configuration configurable = (Configuration) driver(); configurable.setConfiguration(DriverCommand.SEND_KEYS_TO_ELEMENT, "nativeEvents", false); String text = "????"; WebElement inputField = driver().findElement(By.id("name_input")); Assert.assertNotNull(inputField);//from w w w . ja v a 2 s .c o m inputField.clear(); inputField.sendKeys(text); Assert.assertEquals(text, inputField.getAttribute("value")); }
From source file:io.selendroid.nativetests.NativeElementInteractionTest.java
License:Apache License
@Test public void shouldSendKeysAndClearAnElement() { openStartActivity();// w w w . j a va2 s . c o m WebElement inputField = driver().findElement(By.id("my_text_field")); String text = "a.anyString@not.existent%.1.de"; inputField.sendKeys(text); Assert.assertEquals(inputField.getText(), text); inputField.clear(); Assert.assertEquals(inputField.getAttribute("text"), ""); }
From source file:io.selendroid.server.e2e.SessionCreationE2ETests.java
License:Apache License
private void testMethod(SelendroidCapabilities capa) throws Exception { WebDriver driver = new RemoteWebDriver(new URL("http://localhost:5555/wd/hub"), capa); String activityClass = "io.selendroid.testapp." + "HomeScreenActivity"; driver.get("and-activity://" + activityClass); driver.getCurrentUrl();/*from w w w . j av a 2s.com*/ try { driver.findElement(By.id("not there")); Assert.fail(); } catch (NoSuchElementException e) { // expected } WebElement inputField = driver.findElement(By.id("my_text_field")); Assert.assertEquals("true", inputField.getAttribute("enabled")); inputField.sendKeys("Selendroid"); Assert.assertEquals("Selendroid", inputField.getText()); driver.findElement(By.id("buttonStartWebview")).click(); driver.switchTo().window("WEBVIEW"); WebElement element = driver.findElement(By.id("name_input")); element.clear(); ((JavascriptExecutor) driver).executeScript("var inputs = document.getElementsByTagName('input');" + "for(var i = 0; i < inputs.length; i++) { " + " inputs[i].value = 'helloJavascript';" + "}"); Assert.assertEquals("helloJavascript", element.getAttribute("value")); driver.quit(); }
From source file:io.selendroid.tests.SayHelloWebviewTest.java
License:Apache License
@Test public void assertThatWebviewSaysHello() throws Exception { WebElement button = driver().findElement(By.id("buttonStartWebview")); button.click();// w ww .j a v a 2 s. co m WebDriverWait wait = new WebDriverWait(driver(), 10); wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Go to home screen"))); driver().switchTo().window("WEBVIEW"); WebElement inputField = driver().findElement(By.id("name_input")); Assert.assertNotNull(inputField); inputField.clear(); inputField.sendKeys("Dominik"); WebElement car = driver().findElement(By.name("car")); Select preferedCar = new Select(car); preferedCar.selectByValue("audi"); inputField.submit(); WaitingConditions.pageTitleToBe(driver(), "Hello: Dominik"); }
From source file:io.selendroid.tests.UserRegistrationTest.java
License:Apache License
private void registerUser(UserDO user) throws Exception { WebElement button = driver().findElement(By.id("startUserRegistration")); button.click();/*from w w w .j av a 2 s. c o m*/ WebElement username = driver().findElement(By.id("inputUsername")); username.sendKeys(user.getUsername()); WebElement nameInput = driver().findElement(By.id("inputName")); Assert.assertEquals(nameInput.getText(), "Mr. Burns"); nameInput.clear(); nameInput.sendKeys(user.getName()); driver().findElement(By.id("inputEmail")).sendKeys(user.getEmail()); driver().findElement(By.id("inputPassword")).sendKeys(user.getPassword()); try { nameInput.submit(); Assert.fail("submit is not supported by SelendroidNativeDriver"); } catch (WebDriverException e) { // expected behavior } driver().findElement(By.id("input_preferedProgrammingLanguage")).click(); driver().findElement(By.linkText(user.getProgrammingLanguage().getValue())).click(); WebElement acceptAddsCheckbox = driver().findElement(By.id("input_adds")); Assert.assertEquals(acceptAddsCheckbox.isSelected(), false); acceptAddsCheckbox.click(); Assert.assertEquals(driver().getCurrentUrl(), "and-activity://RegisterUserActivity"); try { driver().getTitle(); Assert.fail("Get title is not supported by SelendroidNativeDriver"); } catch (WebDriverException e) { // expected behavior } driver().findElement(By.id("btnRegisterUser")).click(); }
From source file:io.selendroid.webviewdrivertests.WebElementInteractionTest.java
License:Apache License
@Test public void shouldSendKeysAndClearAnElement() { givenWebViewWithFormPageLoaded();//from w ww . j a v a2s . c o m WebElement inputField = driver().findElement(By.id("email")); String text = "a.anyString@not.existent%.1.de"; inputField.sendKeys(text); Assert.assertEquals(inputField.getAttribute("value"), text); inputField.clear(); Assert.assertEquals(inputField.getAttribute("text"), null); }
From source file:io.selendroid.webviewdrivertests.WebElementInteractionTest.java
License:Apache License
@Test() public void shouldSubmitAnElement() { openWebdriverTestPage(HtmlTestData.SAY_HELLO_DEMO); WebElement inputField = driver().findElement(By.id("name_input")); Assert.assertNotNull(inputField);// www. j a v a 2 s .c o m inputField.clear(); inputField.sendKeys("Selendroid"); inputField.submit(); String name = (String) executeJavaScript("return document.title"); Assert.assertEquals(name, "Hello: Selendroid"); }