当前位置: 首页>>代码示例>>Java>>正文


Java WebElement类代码示例

本文整理汇总了Java中org.openqa.selenium.WebElement的典型用法代码示例。如果您正苦于以下问题:Java WebElement类的具体用法?Java WebElement怎么用?Java WebElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebElement类属于org.openqa.selenium包,在下文中一共展示了WebElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: click

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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)"));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaDriverTest.java

示例2: getLocation

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:JavaDriverTest.java

示例3: getRowCount

import org.openqa.selenium.WebElement; //导入依赖的package包/类
/**
 * @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();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:27,代码来源:HiddenHtmlTable.java

示例4: getElement

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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;
    }
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:24,代码来源:GitCrawler.java

示例5: isEnabled

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:JavaDriverTest.java

示例6: decorate

import org.openqa.selenium.WebElement; //导入依赖的package包/类
@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);
}
 
开发者ID:codeborne,项目名称:selenide-appium,代码行数:21,代码来源:SelenideAppiumFieldDecorator.java

示例7: atc

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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;
		}
	}	
}
 
开发者ID:Penor,项目名称:SneakerBot,代码行数:17,代码来源:Adidas.java

示例8: setValue

import org.openqa.selenium.WebElement; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:23,代码来源:RealHtmlMultiSelectList.java

示例9: get_password

import org.openqa.selenium.WebElement; //导入依赖的package包/类
private WebElement get_password() {
	WebElement element = null;
	if (WebUtilities.waitForElementToAppear(driver, password, logger)) {
		element = password;
	}
	return element;
}
 
开发者ID:anilpandeykiet,项目名称:POM_HYBRID_FRAMEOWRK,代码行数:8,代码来源:FlightReservation_Login.java

示例10: waitForElementToNotExist

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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;
	});
}
 
开发者ID:3pillarlabs,项目名称:AutomationFrameworkTPG,代码行数:15,代码来源:BasePage.java

示例11: postMessage

import org.openqa.selenium.WebElement; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:ZabuzaW,项目名称:BrainBridge,代码行数:16,代码来源:BrainInstance.java

示例12: hoverMouseOnWebElement

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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());
	}
}
 
开发者ID:anilpandeykiet,项目名称:POM_HYBRID_FRAMEOWRK,代码行数:9,代码来源:MouseOperations.java

示例13: filterHidden

import org.openqa.selenium.WebElement; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:16,代码来源:WebDriverUtils.java

示例14: clicksOnMenus

import org.openqa.selenium.WebElement; //导入依赖的package包/类
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");
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:JMenuHorizontalTest.java

示例15: checkCssClassDoesNotContain

import org.openqa.selenium.WebElement; //导入依赖的package包/类
@Override
public boolean checkCssClassDoesNotContain(WebElement w, String... args) throws Exception {
	startTime();
	boolean result = currentPage.checkCssClassDoesNotContain(w, args);
	this.setNextPage();
	return result;
}
 
开发者ID:saiscode,项目名称:kheera,代码行数:8,代码来源:TestExecutionController.java


注:本文中的org.openqa.selenium.WebElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。