本文整理汇总了Java中org.openqa.selenium.remote.RemoteWebElement类的典型用法代码示例。如果您正苦于以下问题:Java RemoteWebElement类的具体用法?Java RemoteWebElement怎么用?Java RemoteWebElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemoteWebElement类属于org.openqa.selenium.remote包,在下文中一共展示了RemoteWebElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: windowTitleWithPercentage
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
public void windowTitleWithPercentage() throws Throwable {
driver = new JavaDriver();
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
frame.setTitle("My %Dialog%");
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
WebElement element1 = driver.findElement(By.name("click-me"));
String id1 = ((RemoteWebElement) element1).getId();
// driver.switchTo().window("My %25Dialog%25");
TargetLocator switchTo = driver.switchTo();
switchTo.window("My %Dialog%");
WebElement element2 = driver.findElement(By.name("click-me"));
String id2 = ((RemoteWebElement) element2).getId();
AssertJUnit.assertEquals(id1, id2);
}
示例2: fixLocator
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
private void fixLocator(SearchContext context, String cssLocator,
WebElement element) {
if (element instanceof RemoteWebElement) {
try {
@SuppressWarnings("rawtypes")
Class[] parameterTypes = new Class[] { SearchContext.class,
String.class, String.class };
Method m = element.getClass().getDeclaredMethod(
"setFoundBy", parameterTypes);
m.setAccessible(true);
Object[] parameters = new Object[] { context,
"css selector", cssLocator };
m.invoke(element, parameters);
} catch (Exception fail) {
//NOOP Would like to log here?
}
}
}
示例3: apply
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object apply(Object result) {
if (result instanceof Collection<?>) {
Collection<QAFExtendedWebElement> results = (Collection<QAFExtendedWebElement>) result;
return Lists.newArrayList(Iterables.transform(results, this));
}
result = super.apply(result);
if(result instanceof RemoteWebElement){
if(!(result instanceof QAFExtendedWebElement)){
QAFExtendedWebElement ele = newRemoteWebElement();
ele.setId(((RemoteWebElement)result).getId());
return ele;
}
}
return result;
}
示例4: fixLocator
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
private void fixLocator(SearchContext context, String cssLocator,
WebElement element) {
if (element instanceof RemoteWebElement) {
try {
@SuppressWarnings("rawtypes")
Class[] parameterTypes = new Class[] { SearchContext.class,
String.class, String.class };
Method m = element.getClass().getDeclaredMethod("setFoundBy",
parameterTypes);
m.setAccessible(true);
Object[] parameters = new Object[] { context, "css selector",
cssLocator };
m.invoke(element, parameters);
} catch (Exception e) {
logger.error("Something bad happened when fixing locator", e);
}
}
}
示例5: uploadFile
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
@Override
@Monitor
@RetryFailure(retryCount=3)
@JSHandle
public WebDriverController uploadFile(Object locator, String path) {
LocalFileDetector detector = new LocalFileDetector();
File localFile = detector.getLocalFile(path);
((RemoteWebElement)waitController().waitForElementPresence(locator)).setFileDetector(detector);
waitController().waitForElementPresence(locator).sendKeys(localFile.getAbsolutePath());
return this;
}
示例6: fixLocator
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
private void fixLocator(SearchContext context, String cssLocator,
WebElement element) {
if (element instanceof RemoteWebElement) {
try {
@SuppressWarnings("rawtypes")
Class[] parameterTypes = new Class[] { SearchContext.class,
String.class, String.class };
Method m = element.getClass().getDeclaredMethod(
"setFoundBy", parameterTypes);
m.setAccessible(true);
Object[] parameters = new Object[] { context,
"css selector", cssLocator };
m.invoke(element, parameters);
} catch (Exception fail) {
//NOOP Would like to log here?
}
}
}
示例7: findElementGetsTheSameElementBetweenCalls
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
public void findElementGetsTheSameElementBetweenCalls() 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"));
String id1 = ((RemoteWebElement) element1).getId();
WebElement element2 = driver.findElement(By.name("click-me"));
String id2 = ((RemoteWebElement) element2).getId();
AssertJUnit.assertEquals(id1, id2);
}
示例8: findElementGetsTheSameElementBetweenWindowCalls
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
public void findElementGetsTheSameElementBetweenWindowCalls() 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"));
String id1 = ((RemoteWebElement) element1).getId();
driver.switchTo().window(titleOfWindow);
WebElement element2 = driver.findElement(By.name("click-me"));
String id2 = ((RemoteWebElement) element2).getId();
AssertJUnit.assertEquals(id1, id2);
}
示例9: getLocationInView
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
public void getLocationInView() 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"));
try {
((RemoteWebElement) element1).getCoordinates().inViewPort();
throw new MissingException(WebDriverException.class);
} catch (WebDriverException e) {
}
}
示例10: waitForPageLoad
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
protected final <T> T waitForPageLoad(Func<T> func) {
RemoteWebElement oldHtml = (RemoteWebElement) driver.findElement(By.tagName("html"));
T result = func.call();
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until((WebDriver input) -> {
RemoteWebElement newHtml = (RemoteWebElement) driver.findElement(By.tagName("html"));
return ! newHtml.getId().equals(oldHtml.getId());
});
return result;
}
示例11: getTypeForProxy
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
private Class<?> getTypeForProxy() {
Class<? extends SearchContext> driverClass = originalDriver.getClass();
Iterable<Map.Entry<Class<? extends SearchContext>, Class<? extends WebElement>>> rules =
elementRuleMap.entrySet();
//it will return MobileElement subclass when here is something
for (Map.Entry<Class<? extends SearchContext>, Class<? extends WebElement>> e : rules) {
//that extends AppiumDriver or MobileElement
if (e.getKey().isAssignableFrom(driverClass)) {
return e.getValue();
}
} //it is compatible with desktop browser. So at this case it returns RemoteWebElement.class
return RemoteWebElement.class;
}
示例12: findElement
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
@Override
public WebElement findElement(By by) {
WebElement e = getInstance().findElement(by);
if (e instanceof RemoteWebElement) {
e = new ClickAndWaitRemoteWebElement(e, this);
}
return e;
}
示例13: findElements
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
@Override
public List<WebElement> findElements(By by) {
List<WebElement> list = getInstance().findElements(by);
List<WebElement> newList = new ArrayList<>(list.size());
for (WebElement e : list) {
if (e instanceof RemoteWebElement) {
e = new ClickAndWaitRemoteWebElement(e, this);
}
newList.add(e);
}
return newList;
}
示例14: cleanValueToSend
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
/**
* When send keys is being executed in a input file=type {@link LocalFileDetector} must be configured for remote drivers. Additionally,
* the file path is expanded to be absolute
*
* @param driver used to run commands
* @param element receiving keys
* @param value to be set to input file type
* @return value expanded to absolute path if for input file type.
*/
private String cleanValueToSend(WebDriver driver, WebElement element, String value) {
if (!StringUtils.equals(element.getAttribute(SeleniumFixture.INPUT_TYPE_ATTRIBUTE), SeleniumFixture.INPUT_TYPE_FILE_VALUE)) {
return this.fitnesseMarkup.clean(value);
}
// set file detector for remote web elements. Local FirefoxDriver uses RemoteWebElement and
if (element instanceof RemoteWebElement && !ClassUtils.isAssignable(driver.getClass(), FirefoxDriver.class)) {
((RemoteWebElement) element).setFileDetector(new LocalFileDetector());
}
return this.fitnesseMarkup.cleanFile(value).getAbsolutePath();
}
示例15: tapById
import org.openqa.selenium.remote.RemoteWebElement; //导入依赖的package包/类
public boolean tapById(String id) {
try{
Map<String, ?> params = ImmutableMap.of("element", ((RemoteWebElement)driver.findElement(By.id(id))).getId());
((RobotRemoteWebDriver)this.driver).execute(DriverCommand.TOUCH_SINGLE_TAP, params);
}catch(Exception ex) {
return false;
}
return true;
}