Java Code Examples for org.openqa.selenium.WebElement

The following are top voted examples for showing how to use org.openqa.selenium.WebElement. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: marathonv5   File: JavaDriverTest.java   View source code 9 votes vote down vote up
public void click() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element1 = driver.findElement(By.name("click-me"));
    element1.click();
    AssertJUnit.assertTrue(buttonClicked);
    buttonClicked = false;
    new Actions(driver).click().perform();
    AssertJUnit.assertTrue(buttonClicked);
    AssertJUnit.assertTrue(buttonMouseActions.toString().contains("clicked(1)"));
    buttonMouseActions.setLength(0);
    new Actions(driver).contextClick().perform();
    AssertJUnit.assertTrue(buttonMouseActions.toString(), buttonMouseActions.toString().contains("pressed(3-popup)"));
}
 
Example 2
Project: ats-framework   File: HiddenHtmlTable.java   View source code 6 votes vote down vote up
/**
 * @return how many rows this table has
 */
@Override
@PublicAtsApi
public int getRowCount() {

    new HiddenHtmlElementState(this).waitToBecomeExisting();

    String css = this.getElementProperty("_css");

    List<WebElement> elements = null;

    if (!StringUtils.isNullOrEmpty(css)) {
        css += " tr";
        elements = webDriver.findElements(By.cssSelector(css));
    } else {
        // get elements matching the following xpath
        elements = webDriver.findElements(By.xpath(properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR)
                                                   + "/tr | "
                                                   + properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR)
                                                   + "/*/tr"));
    }

    return elements.size();
}
 
Example 3
Project: testing_security_development_enterprise_systems   File: GitCrawler.java   View source code 6 votes vote down vote up
private static WebElement getElement(WebDriver driver, By by, int current){

        WebElement element = null;

        while(true) {
            try {
                element = driver.findElement(by);
            } catch (Exception e){
                //might happen due to Github blocking crawling
                try {
                    long time = 60_000;
                    System.out.println("Cannot find -> "+by.toString()+"\n Going to wait for "+time+"ms");
                    Thread.sleep(time);
                    openPagedSearchResult(driver, current);
                } catch (InterruptedException e1) {
                }
                continue;
            }
            break;
        }

        return element;
    }
 
Example 4
Project: ats-framework   File: RealHtmlElement.java   View source code 6 votes vote down vote up
/**
 * Drag and drop an element on top of other element
 * @param targetElement the target element
 */
@Override
@PublicAtsApi
public void dragAndDropTo(
                           HtmlElement targetElement ) {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement source = RealHtmlElementLocator.findElement(this);
    WebElement target = RealHtmlElementLocator.findElement(targetElement);

    Actions actionBuilder = new Actions(webDriver);
    Action dragAndDropAction = actionBuilder.clickAndHold(source)
                                            .moveToElement(target, 1, 1)
                                            .release(target)
                                            .build();
    dragAndDropAction.perform();

    // drops the source element in the middle of the target, which in some cases is not doing drop on the right place
    // new Actions( webDriver ).dragAndDrop( source, target ).perform();
}
 
Example 5
Project: marathonv5   File: JavaDriverTest.java   View source code 6 votes vote down vote up
public void isEnabled() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element1 = driver.findElement(By.name("click-me"));
    AssertJUnit.assertTrue(element1.isEnabled());
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            button.setEnabled(false);
        }
    });
    EventQueueWait.waitTillDisabled(button);
    AssertJUnit.assertFalse(element1.isEnabled());
}
 
Example 6
Project: selenide-appium   File: SelenideAppiumFieldDecorator.java   View source code 6 votes vote down vote up
@Override
public Object decorate(ClassLoader loader, Field field) {
  By selector = new Annotations(field).buildBy();
  if (selector instanceof ByIdOrName) {
    // throw new IllegalArgumentException("Please define locator for " + field);
    return decorateWithAppium(loader, field);
  } else if (WebElement.class.isAssignableFrom(field.getType())) {
    return ElementFinder.wrap(searchContext, selector, 0);
  } else if (ElementsCollection.class.isAssignableFrom(field.getType())) {
    return new ElementsCollection(new BySelectorCollection(searchContext, selector));
  } else if (ElementsContainer.class.isAssignableFrom(field.getType())) {
    return createElementsContainer(selector, field);
  } else if (isDecoratableList(field, ElementsContainer.class)) {
    return createElementsContainerList(field);
  } else if (isDecoratableList(field, SelenideElement.class)) {
    return SelenideElementListProxy.wrap(factory.createLocator(field));
  }

  return decorateWithAppium(loader, field);
}
 
Example 7
Project: SneakerBot   File: Adidas.java   View source code 6 votes vote down vote up
public void atc() {
	WebDriverWait wait = new WebDriverWait(driver, 300L);
	
	wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@class='ffSelectButton' and (.//span[text()[contains(.,'Size')]] or .//span[text()[contains(.,'size')]])]")));
	
	int index = new Random().nextInt(sizes.length);
	String sizeToPick = Double.toString(sizes[index]);
	
	for(WebElement e : driver.findElements(By.xpath("//div[@class='ffSelectMenuMid' and .//ul[.//li[.//span[text()[contains(.,'size')]]]]]/ul/li"))) {
		String size = e.getText().trim();
		if(size != null && size.equals(sizeToPick)) {
			e.click();
			break;
		}
	}	
}
 
Example 8
Project: ats-framework   File: RealHtmlMultiSelectList.java   View source code 6 votes vote down vote up
/**
 * select a value
 *
 * @param value the value to select
 */
@Override
@PublicAtsApi
public void setValue(
                      String value ) {

    new RealHtmlElementState(this).waitToBecomeExisting();

    try {
        WebElement element = RealHtmlElementLocator.findElement(this);
        Select select = new Select(element);
        select.selectByVisibleText(value);
    } catch (NoSuchElementException nsee) {
        throw new SeleniumOperationException("Option with label '" + value + "' not found. ("
                                             + this.toString() + ")");
    }
    UiEngineUtilities.sleep();
}
 
Example 9
Project: POM_HYBRID_FRAMEOWRK   File: FlightReservation_Login.java   View source code 5 votes vote down vote up
private WebElement get_password() {
	WebElement element = null;
	if (WebUtilities.waitForElementToAppear(driver, password, logger)) {
		element = password;
	}
	return element;
}
 
Example 10
Project: AutomationFrameworkTPG   File: BasePage.java   View source code 5 votes vote down vote up
protected void waitForElementToNotExist(WebElement element) {
	new WebDriverWait(getDriverProxy(), 20)
	.withMessage("Timed out waiting for element to not exist.")
	.until((WebDriver d) -> {
		boolean conditionMet = false;
		try {
			// We don't really care whether it's displayed or not, just if it exists.
			element.isDisplayed();
		} catch (NoSuchElementException | StaleElementReferenceException e) {
			conditionMet = true;
		}
		return conditionMet;
	});
}
 
Example 11
Project: BrainBridge   File: BrainInstance.java   View source code 5 votes vote down vote up
/**
 * Posts the given message to the brain chat.
 * 
 * @param message
 *            The message to post
 */
public void postMessage(final String message) {
	updateLastUsage();
	switchToWindow();
	switchToFrame(CHAT_INPUT_FRAME_NAME);

	final WebElement input = new NamePresenceWait(this.mDriver, CHAT_INPUT_NAME).waitUntilCondition();
	input.sendKeys(message);
	input.sendKeys(Keys.ENTER);
}
 
Example 12
Project: POM_HYBRID_FRAMEOWRK   File: MouseOperations.java   View source code 5 votes vote down vote up
public static void hoverMouseOnWebElement(WebDriver driver, ExtentTest logger, WebElement element) {
	try {
		Actions action = new Actions(driver);
		action.moveToElement(element).build().perform();
	} catch (Exception e) {
		logger.log(LogStatus.ERROR, "Error hovering over the element</br>" + e.getCause());
	}
}
 
Example 13
Project: Selenium-Foundation   File: WebDriverUtils.java   View source code 5 votes vote down vote up
/**
 * Remove hidden elements from specified list
 * 
 * @param elements list of elements
 * @return 'true' if no visible elements were found; otherwise 'false'
 */
public static boolean filterHidden(List<WebElement> elements) {
    Iterator<WebElement> iter = elements.iterator();
    while (iter.hasNext()) {
        if ( ! iter.next().isDisplayed()) {
            iter.remove();
        }
    }
    return elements.isEmpty();
}
 
Example 14
Project: marathonv5   File: JMenuHorizontalTest.java   View source code 5 votes vote down vote up
public void clicksOnMenus() throws Throwable {
    driver = new JavaDriver();
    List<WebElement> menus = driver.findElements(By.cssSelector("menu"));
    int i = 0;
    clicksOnMenu(menus, i++, "Menu 1");
    clicksOnMenu(menus, i++, "Menu 2");
    clicksOnMenu(menus, i++, "Menu 3");
}
 
Example 15
Project: kheera   File: TestExecutionController.java   View source code 5 votes vote down vote up
@Override
public boolean checkCssClassDoesNotContain(WebElement w, String... args) throws Exception {
	startTime();
	boolean result = currentPage.checkCssClassDoesNotContain(w, args);
	this.setNextPage();
	return result;
}
 
Example 16
Project: ats-framework   File: RealHtmlElement.java   View source code 5 votes vote down vote up
/**
 * Simulate Tab key
 */
@Override
@PublicAtsApi
public void pressTabKey() {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement element = RealHtmlElementLocator.findElement(this);
    element.sendKeys(Keys.TAB);
}
 
Example 17
Project: Cognizant-Intelligent-Test-Scripter   File: AutomationObject.java   View source code 5 votes vote down vote up
public WebElement findElement(SearchContext element, String objectKey, String pageKey, String Attribute, FindType condition) {
    pageName = pageKey;
    objectName = objectKey;
    findType = condition;
    return getElementFromList(findElements(element,
            getORObject(pageKey, objectKey), Attribute));
}
 
Example 18
Project: bootstrap   File: TAbstractSeleniumTest.java   View source code 5 votes vote down vote up
@Test
public void testAssertElementAttribute() {
	final WebElement webElement = Mockito.mock(WebElement.class);
	Mockito.when(webElement.getAttribute(ArgumentMatchers.any())).thenReturn(null).thenReturn("value");
	Mockito.when(mockDriver.findElement(ArgumentMatchers.any())).thenReturn(webElement);
	assertElementAttribute("value", null, null);
}
 
Example 19
Project: marathonv5   File: JTextAreaTest.java   View source code 5 votes vote down vote up
void getAttributes() throws Throwable {
    driver = new JavaDriver();
    WebElement textArea = driver.findElement(By.cssSelector("text-area"));
    AssertJUnit.assertEquals("true", textArea.getAttribute("editable"));
    textArea.sendKeys("Systems", Keys.SPACE);
    String previousText = textArea.getText();
    textArea.clear();
    textArea.sendKeys("Jalian" + previousText);
}
 
Example 20
Project: spring-reactive-sample   File: HomePage.java   View source code 5 votes vote down vote up
public List<Attribute> attributes() {
	List<Attribute> rows = new ArrayList<>();
	for (WebElement tr : this.trs) {
		rows.add(new Attribute(tr));
	}
	this.attributes.addAll(rows);
	return this.attributes;
}
 
Example 21
Project: Selenium-Foundation   File: JsUtilityTest.java   View source code 5 votes vote down vote up
private String getMetaTagNamed(WebDriver driver, String name) {
    JsUtility.injectGlueLib(driver);
    String script = JsUtility.getScriptResource("requireMetaTagByName.js");
     
    try {
        WebElement response = JsUtility.runAndReturn(driver, script, name);
        return response.getAttribute("content");
    } catch (WebDriverException e) {
        throw JsUtility.propagate(e);
    }
}
 
Example 22
Project: phoenix.webui.framework   File: SeleniumIFrameLocator.java   View source code 5 votes vote down vote up
@Override
public WebElement findElement(SearchContext driver)
{
	if(!(driver instanceof WebDriver))
	{
		throw new IllegalArgumentException("Argument must be instanceof WebDriver.");
	}
	
	WebDriver webDriver = (WebDriver) driver;
	
	webDriver = engine.turnToRootDriver(webDriver);
	if(!iframeWait(webDriver, getTimeout(), getValue()))
	{
		webDriver.switchTo().frame(getValue());
	}
	
	return null;
}
 
Example 23
Project: SWET   File: SwetTest.java   View source code 5 votes vote down vote up
@Test
public void testChangeElementSelectedBy() {
	driver.get(utils.getResourceURI("ElementSearch.html"));
	utils.injectScripts(Optional.<String> empty());
	WebElement target = wait.until(
			ExpectedConditions.visibilityOf(driver.findElement(By.tagName("h1"))));
	utils.highlight(target);
	// Act
	utils.inspectElement(target);
	// Assert
	List<String> labels = driver
			.findElements(By.cssSelector("form#SWDForm label[for]")).stream()
			.map(e -> e.getAttribute("for")).collect(Collectors.toList());

	String lastLabel = null;
	Collections.sort(labels, String.CASE_INSENSITIVE_ORDER);
	for (String label : labels) {
		utils.sleep(100);
		WebElement radioElement = wait.until(ExpectedConditions.visibilityOf(
				driver.findElement(By.xpath(String.format("//*[@id='%s']", label)))));
		assertThat(radioElement, notNullValue());
		radioElement.click();
		lastLabel = label;
	}
	utils.completeVisualSearch("changing strategy attribute");
	// Assert
	String payload = utils.getPayload();
	assertFalse(payload.isEmpty());
	Map<String, String> details = new HashMap<>();
	utils.readData(payload, Optional.of(details));
	verifyNeededKeys(details);
	verifyEntry(details, "ElementSelectedBy", lastLabel);
}
 
Example 24
Project: hippo   File: DatasetPageElements.java   View source code 5 votes vote down vote up
@Override
public WebElement getElementByName(String elementName, int nth, WebDriver webDriver) {
    List<WebElement> elements = webDriver.findElements(pageElements.get(elementName));

    if (elements.size() == 0) {
        return null;
    }

    return elements.get(nth);
}
 
Example 25
Project: selenium-toys   File: TypeTest.java   View source code 5 votes vote down vote up
@Test
public void onTest() {
  final WebDriver webDriver = Mockito.mock(WebDriver.class);
  final WebElement webElement = Mockito.mock(WebElement.class);

  final Type type = new Type(webDriver, "text", () -> {});
  final By byId = By.id("id");
  Mockito.when(webDriver.findElement(byId)).thenReturn(webElement);
  type.on(byId);
  Mockito.verify(webElement).sendKeys("text");
}
 
Example 26
Project: marathonv5   File: JavaDriverTest.java   View source code 5 votes vote down vote up
public void getLocation() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element1 = driver.findElement(By.name("click-me"));
    Point location = element1.getLocation();
    java.awt.Point p = EventQueueWait.call(button, "getLocation");
    AssertJUnit.assertEquals(p.x, location.x);
    AssertJUnit.assertEquals(p.y, location.y);
}
 
Example 27
Project: POM_HYBRID_FRAMEOWRK   File: FlightReservation_Login.java   View source code 5 votes vote down vote up
private WebElement get_signInButton() {
	WebElement element = null;
	if (WebUtilities.waitForElementToAppear(driver, signInButton, logger)) {
		element = signInButton;
	}
	return element;
}
 
Example 28
Project: BrainBridge   File: BrainInstance.java   View source code 5 votes vote down vote up
/**
 * Shuts this instance down and frees all used resources.
 */
public void shutdown() {
	switchToWindow();
	switchToFrame(CHAT_INPUT_FRAME_NAME);

	final WebElement logoutAnchor = new CSSSelectorPresenceWait(this.mDriver, LOGOUT_ANCHOR).waitUntilCondition();
	logoutAnchor.click();

	this.mDriver.close();
}
 
Example 29
Project: hippo   File: SiteSteps.java   View source code 5 votes vote down vote up
@Then("I can download(?: following files)?:")
public void iCanDownload(final DataTable downloadTitles) throws Throwable {
    for (List<String> downloadLink : downloadTitles.asLists(String.class)) {
        String linkText = downloadLink.get(0);
        String linkFileName = downloadLink.get(1);

        WebElement downloadElement = sitePage.findElementWithTitle(linkText);

        assertThat("I can find download link with title: " + linkText,
            downloadElement, is(notNullValue()));

        String url = downloadElement.getAttribute("href");
        assertEquals("I can find link with expected URL for file " + linkFileName, URL + urlLookup.lookupUrl(linkFileName), url);

        if (acceptanceTestProperties.isHeadlessMode()) {
            // At the moment of writing, there doesn't seem to be any easy way available to force Chromedriver
            // to download files when operating in headless mode. It appears that some functionality has been
            // added to DevTools but it's not obvious how to trigger that from Java so, for now at least,
            // we'll only be testing file download when operating in a full, graphical mode.
            //
            // See bug report at https://bugs.chromium.org/p/chromium/issues/detail?id=696481 and other reports
            // available online.
            log.warn("Not testing file download due to running in a headless mode, will just check link is present.");
        } else {
            // Trigger file download by click the <a> tag.
            sitePage.clickOnElement(downloadElement);

            final Path downloadedFilePath = Paths.get(acceptanceTestProperties.getDownloadDir().toString(),
                linkFileName);

            waitUntilFileAppears(downloadedFilePath);
        }
    }
}
 
Example 30
Project: ats-framework   File: RealHtmlElement.java   View source code 5 votes vote down vote up
/**
 * Simulate mouse double click action
 */
@Override
@PublicAtsApi
public void doubleClick() {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement element = RealHtmlElementLocator.findElement(this);

    new Actions(webDriver).doubleClick(element).perform();
}
 
Example 31
Project: bootstrap   File: TAbstractSeleniumTest.java   View source code 5 votes vote down vote up
@Test
public void testAssertSelectedText() {
	final WebElement webElement = Mockito.mock(WebElement.class);
	Mockito.when(mockDriver.findElement(ArgumentMatchers.any())).thenReturn(webElement);
	Mockito.when(webElement.getTagName()).thenReturn("select");
	final List<WebElement> items = new ArrayList<>();
	items.add(webElement);
	Mockito.when(webElement.findElements(ArgumentMatchers.any())).thenReturn(items);
	Mockito.when(webElement.isSelected()).thenReturn(true);
	Mockito.when(webElement.getText()).thenReturn("text");
	assertSelectedText("text", null);
}
 
Example 32
Project: devtools-driver   File: ExampleMobileSafariWebTest.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  // Create a DesiredCapabilities object to request specific devices from the WebDriver server.
  // A udid can be optionally specified, otherwise an arbitrary device is chosen.
  DesiredCapabilities caps = new DesiredCapabilities();
  // caps.setCapability("uuid", udid);
  // Start a WebDriver session. The local machine has to be running the SafariDriverServer, or
  // change localhost below to an IP running the SafariDriverServer.
  driver = new RemoteWebDriver(new URL("http://localhost:5555/wd/hub"), caps);
  // Connect to a URL
  driver.get("http://www.google.com");

  // Interact with the web page. In this example use case, the Webdriver API is used to find
  // specific elements, test a google search and take a screenshot.
  driver.findElement(By.id("hplogo"));

  // Google New York
  WebElement mobileSearchBox = driver.findElement(By.id("lst-ib"));
  mobileSearchBox.sendKeys("New York");
  WebElement searchBox;
  try {
    searchBox = driver.findElement(By.id("tsbb"));
  } catch (NoSuchElementException e) {
    searchBox = driver.findElement(By.name("btnG"));
  }
  searchBox.click();

  takeScreenshot();
  driver.navigate().refresh();
  takeScreenshot();

  // Quit the WebDriver instance on completion of the test.
  driver.quit();
  driver = null;
}
 
Example 33
Project: teasy   File: SelectImpl.java   View source code 5 votes vote down vote up
@Override
public void selectByAnotherTextThan(final String text) {
    final org.openqa.selenium.support.ui.Select select = wrappedSelect();
    final List<WebElement> options = select.getOptions();
    for (int i = options.size() - 1; i >= 0; i--) {
        final WebElement each = options.get(i);
        if (!each.getText().equals(text)) {
            select.selectByIndex(i);
            return;
        }
    }
}
 
Example 34
Project: marathonv5   File: JTableTest.java   View source code 5 votes vote down vote up
public void tableCellEditSelectByProps() throws Throwable {
    driver = new JavaDriver();
    String selector = "{ \"select\": \"{2, Sport}\" }";
    WebElement cell = driver.findElement(By.cssSelector("table::select-by-properties('" + selector + "')::editor"));
    AssertJUnit.assertEquals("text-field", cell.getTagName());
    cell.clear();
    cell.sendKeys("Hello World", Keys.ENTER);
    cell = driver.findElement(By.cssSelector("table::mnth-cell(3,3)"));
    AssertJUnit.assertEquals("Hello World", cell.getText());
    cell = driver.findElement(By.cssSelector("table::mnth-cell(3,5)"));
    AssertJUnit.assertEquals("boolean-renderer", cell.getTagName());
    cell = driver.findElement(By.cssSelector("table::mnth-cell(3,5)::editor"));
    AssertJUnit.assertEquals("check-box", cell.getTagName());
}
 
Example 35
Project: kheera   File: TestExecutionController.java   View source code 5 votes vote down vote up
@Override
public boolean clickElement(WebElement w) throws Exception {
	startTime();
	boolean result = currentPage.clickElement(w);
	this.setNextPage();
	return result;
}
 
Example 36
Project: SilkAppDriver   File: ExceptionTests.java   View source code 5 votes vote down vote up
@After
public void closeApp() {
	WebElement fileMenu = driver.findElement(By.xpath("//Menu[@caption='File']"));
	fileMenu.click();

	WebElement exit = driver.findElement(By.xpath("//MenuItem[@caption='Exit']"));
	exit.click();

	driver.quit();
}
 
Example 37
Project: marathonv5   File: JMenuHorizontalTest.java   View source code 5 votes vote down vote up
private void assertClicksOnMenuItemsInSubMenu(WebElement menu) throws Throwable {
    menu.click();
    List<WebElement> includeSubMenus = driver.findElements(By.cssSelector("menu"));
    AssertJUnit.assertEquals(4, includeSubMenus.size());
    WebElement subMenu = includeSubMenus.get(3);
    AssertJUnit.assertEquals("Submenu", subMenu.getText());

    List<WebElement> menuItems = driver.findElements(By.cssSelector("menu-item"));
    AssertJUnit.assertEquals(3, menuItems.size());
    menu.click();

    assertClicks(menu, subMenu, 3);
}
 
Example 38
Project: colibri-ui-template   File: AndroidDynamicFieldSteps.java   View source code 5 votes vote down vote up
@Step
@Then("значение динамического поля \"$field\" равно \"$expectedValue\"")
public void stepCheckValueInDynamicFields(@Named("$field") String field, @Named("$expectedValue") String expectedValue) {
    IElement parent = getCurrentPage().getElementByName(field);
    IElement nested = pageProvider.getPageByName(DYNAMIC_FIELDS_PAGE_NAME).getElementByName(EDIT_TEXT_NAME);
    WebElement elementFound = finder.findNestedWebElement(parent, nested);
    String actualElement = elementFound.getText();
    assertEquals(format("Значение поля [%s] не соответствует ожидаемому [%s]", actualElement, expectedValue), expectedValue, actualElement);
}
 
Example 39
Project: marathonv5   File: JavaDriverTest.java   View source code 5 votes vote down vote up
public void elementSendKeys() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    AssertJUnit.assertEquals("", EventQueueWait.call(textField, "getText"));
    WebElement element1 = driver.findElement(By.name("text-field"));
    element1.sendKeys("Hello", " ", "World");
    AssertJUnit.assertEquals("Hello World", EventQueueWait.call(textField, "getText"));
}
 
Example 40
Project: marathonv5   File: JTableTest.java   View source code 5 votes vote down vote up
public void getheader() throws Throwable {
    driver = new JavaDriver();
    WebElement header = driver.findElement(By.cssSelector("table::header"));
    AssertJUnit.assertEquals(5 + "", header.getAttribute("count"));
    WebElement header2 = driver.findElement(By.cssSelector("table-header"));
    AssertJUnit.assertEquals(5 + "", header2.getAttribute("count"));
}