List of usage examples for org.openqa.selenium WebElement getText
String getText();
From source file:com.github.wiselenium.elements.component.impl.MultiSelectImpl.java
License:Open Source License
@Override public List<String> getSelectedVisibleTexts() { List<String> texts = Lists.newArrayList(); List<WebElement> selectedOptions = this.getWrappedSelect().getAllSelectedOptions(); for (WebElement option : selectedOptions) texts.add(option.getText()); return texts; }
From source file:com.google.android.testing.nativedriver.TextValueTest.java
License:Apache License
public void testTextValue() { driver.startActivity("com.google.android.testing.nativedriver" + ".simplelayouts.TextValueActivity"); WebElement textView = driver.findElement(By.id("TextView01")); assertEquals("Hello, Android NativeDriver!", textView.getText()); WebElement textEditView = driver.findElement(By.id("EditText01")); textEditView.clear();//from www.j ava2s. c o m textEditView.sendKeys("this is some input"); assertEquals("this is some input", textEditView.getText()); }
From source file:com.google.appengine.tck.channel.ChannelTest.java
License:Open Source License
@Test @RunAsClient//from ww w . j a va 2 s .co m @InSequence(10) public void testSimpleMessage(@ArquillianResource URL url) throws Exception { // 1. Create our test with a unique channel id. final String channelId = String.valueOf(System.currentTimeMillis()); driver.get(url + "/channelPage.jsp?test-channel-id=" + channelId); // 2. Verify that the server received our channel id and is using it for this tests. WebElement channel = driver.findElement(By.id("channel-id")); assertEquals(channelId, channel.getText()); // 3. The browser waits for the channel to be opened. There is an implicit timeout of 30 seconds if it is not found. Graphene.waitModel(driver).until().element(By.id("opened-" + channelId)).is().present(); // 4. Send a message via channel to the server. WebElement sendButton = driver.findElement(By.id("send-message-button")); sendButton.click(); // 4. Check that we attempted to send a message from the browser to server. Graphene.waitModel(driver).until().element(By.id("last-sent-message-" + channelId)).is().present(); // 5. Now verify that the browser got the ACK from the server. String receivedMsgId = "last-received-message-" + channelId; Graphene.waitModel(driver).until().element(By.id(receivedMsgId)).is().present(); WebElement lastReceived = driver.findElement(By.id(receivedMsgId)); String expectedMsg = "echo-from-server:msg:" + channelId; assertEquals(expectedMsg, lastReceived.getText()); }
From source file:com.google.appengine.tck.channel.ChannelTest.java
License:Open Source License
@Test @RunAsClient//w w w . j a v a 2s . c o m @InSequence(20) public void testTimeout(@ArquillianResource URL url) throws Exception { // 1. Create our test with a unique channel id. final String channelId = "" + System.currentTimeMillis(); // Set timeout for 1 minute. String params = String.format("/channelPage.jsp?test-channel-id=%s&timeout-minutes=%d", channelId, 1); driver.get(url + params); // 2. Verify that the server received our channel id and is using it for this tests. WebElement channel = driver.findElement(By.id("channel-id")); assertEquals(channelId, channel.getText()); // 3. Verify that the channel gets closed after the 1 minute timeout. Graphene.waitModel(driver).until().element(By.id("status")).text().equalTo("opened"); // This should put us over the 1 minute timeout. Graphene.waitModel(driver).withTimeout(90, TimeUnit.SECONDS).until().element(By.id("status")).text() .equalTo("closed"); }
From source file:com.google.caja.plugin.ThirdPartyBrowserTest.java
License:Apache License
/** * For QUnit-based tests, read QUnit's status text to determine if progress is * being made./*from w w w. j a v a 2 s.c o m*/ */ @Override protected void waitForCompletion(final WebDriver driver) { final String testResultId = "qunit-testresult-caja-guest-0___"; if (driver.findElements(By.id(testResultId)).size() == 0) { // Not a QUnit test case; use default behavior. super.waitForCompletion(driver); return; } // Let it run as long as the report div's text is changing WebElement statusElement = driver.findElement(By.id(testResultId)); String currentStatus = statusElement.getText(); String lastStatus = null; // Check every second. // If the text starts with "Tests completed", then we're done. // If the text has changed, reset the time limit. int limit = 30; // tries for (int chances = limit; chances > 0; --chances) { if (currentStatus.startsWith("Tests completed")) { break; } try { Thread.sleep(1000); } catch (InterruptedException e) { // Keep trying } statusElement = driver.findElement(By.id(testResultId)); lastStatus = currentStatus; currentStatus = statusElement.getText(); if (!lastStatus.equals(currentStatus)) { chances = limit; } } }
From source file:com.gorillalogic.agents.html.automators.ItemSelectorAutomator.java
License:Open Source License
protected String select(Command command) { List<String> selected = command.getArgs(); int successCount = 0; // We may want to deselect all if we do not have deselect action if (getSelect().isMultiple()) { getSelect().deselectAll();/*ww w . j a v a 2s . c om*/ } int i = 0; for (WebElement option : getSelect().getOptions()) { for (String selection : selected) { if (selection.equals(option.getText()) || selection.equals(option.getAttribute("value"))) { getSelect().selectByIndex(i); successCount++; } } i++; } if (successCount == command.getArgs().size()) return null; throw new IllegalArgumentException("Invalid selection value '" + command.getArgsAsString() + "'"); }
From source file:com.gwtplatform.carstore.cucumber.application.cars.EditCarsPage.java
License:Apache License
public String getCurrentCarTabName() { WebElement selectedTab = carsTabs.findElement(By.className("gwt-TabBarItem-selected")); WebElement tabNameContainer = selectedTab.findElement(By.cssSelector("span")); return tabNameContainer.getText(); }
From source file:com.gwtplatform.carstore.cucumber.application.PageWithEditTable.java
License:Apache License
protected int getColumnIndex(WebElement table, String columnName) { List<WebElement> tableHeaders = table.findElements(By.cssSelector("thead th")); int index = 1; for (WebElement tableHeader : tableHeaders) { if (columnName.equals(tableHeader.getText())) { return index; }// w ww .j a v a2 s .co m index++; } return 0; }
From source file:com.gwtplatform.carstore.cucumber.application.stats.StatsPage.java
License:Apache License
private Date getCurrentDatePickerDate(SimpleDateFormat dateFormat, WebElement datePickerMonth) { Date datePickerDate;/*from ww w. jav a 2 s .c o m*/ try { datePickerDate = dateFormat.parse(datePickerMonth.getText()); } catch (ParseException e) { throw new RuntimeException(e); } return datePickerDate; }