• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TargetLocator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: HiddenHtmlPrompt

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
public HiddenHtmlPrompt( UiDriver uiDriver ) {

        super(uiDriver);

        HiddenBrowserDriver browserDriver = (HiddenBrowserDriver) uiDriver;
        HtmlUnitDriver driver = (HtmlUnitDriver) browserDriver.getInternalObject(InternalObjectsEnum.WebDriver.name());
        Field webClientField = null;
        boolean fieldAccessibleState = false;
        try {

            TargetLocator targetLocator = driver.switchTo();
            webClientField = targetLocator.getClass().getDeclaringClass().getDeclaredField("webClient");
            fieldAccessibleState = webClientField.isAccessible();
            webClientField.setAccessible(true);
            webClient = (WebClient) webClientField.get(targetLocator.defaultContent());

        } catch (Exception e) {

            throw new SeleniumOperationException("Error retrieving internal Selenium web client", e);
        } finally {

            if (webClientField != null) {
                webClientField.setAccessible(fieldAccessibleState);
            }
        }
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:27,代码来源:HiddenHtmlPrompt.java


示例2: windowTitleWithPercentage

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


示例3: HiddenHtmlAlert

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
public HiddenHtmlAlert( UiDriver uiDriver ) {

        super(uiDriver);

        HiddenBrowserDriver browserDriver = (HiddenBrowserDriver) uiDriver;
        HtmlUnitDriver driver = (HtmlUnitDriver) browserDriver.getInternalObject(InternalObjectsEnum.WebDriver.name());
        Field webClientField = null;
        boolean fieldAccessibleState = false;
        try {

            TargetLocator targetLocator = driver.switchTo();
            webClientField = targetLocator.getClass().getDeclaringClass().getDeclaredField("webClient");
            fieldAccessibleState = webClientField.isAccessible();
            webClientField.setAccessible(true);
            webClient = (WebClient) webClientField.get(targetLocator.defaultContent());
        } catch (Exception e) {

            throw new SeleniumOperationException("Error retrieving internal Selenium web client", e);
        } finally {

            if (webClientField != null) {
                webClientField.setAccessible(fieldAccessibleState);
            }
        }
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:26,代码来源:HiddenHtmlAlert.java


示例4: HiddenHtmlConfirm

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
public HiddenHtmlConfirm( UiDriver uiDriver ) {

        super(uiDriver);

        HiddenBrowserDriver browserDriver = (HiddenBrowserDriver) uiDriver;
        HtmlUnitDriver driver = (HtmlUnitDriver) browserDriver.getInternalObject(InternalObjectsEnum.WebDriver.name());
        Field webClientField = null;
        boolean fieldAccessibleState = false;
        try {

            TargetLocator targetLocator = driver.switchTo();
            webClientField = targetLocator.getClass().getDeclaringClass().getDeclaredField("webClient");
            fieldAccessibleState = webClientField.isAccessible();
            webClientField.setAccessible(true);
            webClient = (WebClient) webClientField.get(targetLocator.defaultContent());

        } catch (Exception e) {

            throw new SeleniumOperationException("Error retrieving internal Selenium web client", e);
        } finally {

            if (webClientField != null) {
                webClientField.setAccessible(fieldAccessibleState);
            }
        }
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:27,代码来源:HiddenHtmlConfirm.java


示例5: onCommand

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Object onCommand(Context context) {
    TargetLocator tl = getSession().switchTo();
    if (index >= 0) {
        tl.frame(index);
    }
    if (StringUtils.isNotBlank(name)) {
        tl.frame(name);
    }
    if (top != null && top) {
        tl.defaultContent();
    }
    return null;
}
 
开发者ID:niuxuetao,项目名称:paxml,代码行数:18,代码来源:FrameTag.java


示例6: testExceptionHandlingInCaseAFrameIsNotFoundForTheGivenIndex

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test(expected = NoSuchFrameException.class)
public void testExceptionHandlingInCaseAFrameIsNotFoundForTheGivenIndex() {

    TargetLocator locator = mockTargetLocator();
    NoSuchFrameException exception = createSeleniumExceptionOfClass(NoSuchFrameException.class);
    doThrow(exception).when(locator).frame(INDEX);

    try {
        cut.setFocusOnFrame(INDEX);
    } finally {
        verifyLastEventFiredWasExceptionEventOf(exception);
    }

}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:15,代码来源:WebDriverBrowserTest.java


示例7: testExceptionHandlingInCaseAFrameIsNotFoundForTheGivenNameOrId

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test(expected = NoSuchFrameException.class)
public void testExceptionHandlingInCaseAFrameIsNotFoundForTheGivenNameOrId() {

    TargetLocator locator = mockTargetLocator();
    NoSuchFrameException exception = createSeleniumExceptionOfClass(NoSuchFrameException.class);
    doThrow(exception).when(locator).frame(NAME_OR_ID);

    try {
        cut.setFocusOnFrame(NAME_OR_ID);
    } finally {
        verifyLastEventFiredWasExceptionEventOf(exception);
    }

}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:15,代码来源:WebDriverBrowserTest.java


示例8: testExceptionHandlingInCaseAWindowIsNotFoundForTheGivenNameOrHandle

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test(expected = NoSuchWindowException.class)
public void testExceptionHandlingInCaseAWindowIsNotFoundForTheGivenNameOrHandle() {

    TargetLocator locator = mockTargetLocator();
    NoSuchWindowException exception = createSeleniumExceptionOfClass(NoSuchWindowException.class);
    doThrow(exception).when(locator).window(NAME_OR_HANDLE);

    try {
        cut.setFocusOnWindow(NAME_OR_HANDLE);
    } finally {
        verifyLastEventFiredWasExceptionEventOf(exception);
    }

}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:15,代码来源:WebDriverBrowserTest.java


示例9: switchTo

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Override
public WebDriver switchTo(TargetLocator targetLocator) {
    // This is ugly :(
    if (targetLocator instanceof CachingTargetLocator) {
        return ((CachingTargetLocator) targetLocator).frame(parent, index);
    }
    
    parent.switchTo(targetLocator);
    return targetLocator.frame(index);
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:11,代码来源:WebDriverTargets.java


示例10: findWindow

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
private String findWindow(TargetLocator targetLocator) {
    for (String windowHandle : targetLocator.defaultContent().getWindowHandles()) {
        Browser forWindowHandle = By.id(windowHandle).find(Browser.class, parentContext);

        view.setContext(forWindowHandle);

        if (view.isLoaded()) {
            return windowHandle;
        }
    }

    throw new NoSuchWindowException("No window in driver found which has " + view + " "
            + "currently loaded.");
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:15,代码来源:WebDriverTargets.java


示例11: switchTo

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
public TargetLocator switchTo() {
    return driver.switchTo();
}
 
开发者ID:lithiumtech,项目名称:mineraloil-selenium,代码行数:4,代码来源:WebdriverActions.java


示例12: testThatSwitchingToFrameWithIndexInvokesCorrectLocatorMethod

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test
public void testThatSwitchingToFrameWithIndexInvokesCorrectLocatorMethod() {
    TargetLocator locator = mockTargetLocator();
    cut.setFocusOnFrame(INDEX);
    verify(locator).frame(INDEX);
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:7,代码来源:WebDriverBrowserTest.java


示例13: testThatSwitchingToFrameWithNameOrIdInvokesCorrectLocatorMethod

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test
public void testThatSwitchingToFrameWithNameOrIdInvokesCorrectLocatorMethod() {
    TargetLocator locator = mockTargetLocator();
    cut.setFocusOnFrame(NAME_OR_ID);
    verify(locator).frame(NAME_OR_ID);
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:7,代码来源:WebDriverBrowserTest.java


示例14: testThatSwitchingToWindowWithNameOrHanldeInvokesCorrectLocatorMethod

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test
public void testThatSwitchingToWindowWithNameOrHanldeInvokesCorrectLocatorMethod() {
    TargetLocator locator = mockTargetLocator();
    cut.setFocusOnWindow(NAME_OR_HANDLE);
    verify(locator).window(NAME_OR_HANDLE);
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:7,代码来源:WebDriverBrowserTest.java


示例15: testThatSwitchingToDefaultContentInvokesCorrectLocatorMethod

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
@Test
public void testThatSwitchingToDefaultContentInvokesCorrectLocatorMethod() {
    TargetLocator locator = mockTargetLocator();
    cut.setFocusOnDefaultContent();
    verify(locator).defaultContent();
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:7,代码来源:WebDriverBrowserTest.java


示例16: mockTargetLocator

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
private TargetLocator mockTargetLocator() {
    TargetLocator locator = mock(TargetLocator.class);
    doReturn(locator).when(webDriver).switchTo();
    return locator;
}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:6,代码来源:WebDriverBrowserTest.java


示例17: TargetedWebDriverParentContext

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
/**
 * @param myTarget Parent contexts must be targeted because frame targets depend on another,
 *         "parent" target. So each parent context must have its own WebDriver target that is
 *         associated with, because this state is used when finding frames.
 * @param locator Means of finding other WebDrivers for new targets. Each new browser shares the
 *         same locator.
 * @param knowsWindowHandles Finds open windows' handles. Must be associated with the same
 *         driver as the {@code locator}.
 * @param elementMap Each new browser must have an element conFunction or type which can provide the current set of window
 *         handles of the driver associated with the locator.structor map so it may create
 */
public TargetedWebDriverParentContext(WebDriverTarget myTarget, TargetLocator locator,
        KnowsWindowHandles knowsWindowHandles, ElementConstructorMap elementMap) {
    this.myTarget = myTarget;
    this.locator = locator;
    this.knowsWindowHandles = knowsWindowHandles;
    this.elementMap = elementMap;
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:19,代码来源:TargetedWebDriverParentContext.java


示例18: BobcatTargetLocator

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
/**
 * Constructs TargetLocatorWrapper.
 *
 * @param targetLocator instance of TargetLocator.
 * @param frameSwitcher instance of FrameSwitcher.
 */
public BobcatTargetLocator(TargetLocator targetLocator, FrameSwitcher frameSwitcher) {
  super();
  this.targetLocator = targetLocator;
  this.frameSwitcher = frameSwitcher;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:12,代码来源:BobcatTargetLocator.java


示例19: switchTo

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
/**
 * @throws org.openqa.selenium.NotFoundException if this target is not able to be switched to,
 * as per {@link WebDriver#switchTo()} behavior.
 */
WebDriver switchTo(TargetLocator targetLocator);
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:6,代码来源:WebDriverTarget.java


示例20: switchTo

import org.openqa.selenium.WebDriver.TargetLocator; //导入依赖的package包/类
/**
 * Issues a log message before executing {@link WebDriver#switchTo()}.
 *
 * @return A TargetLocator which can be used to select a frame or window
 */
public TargetLocator switchTo() {
	LOGGER.info("Switching WebDriver...");
	return webDriver.switchTo();
}
 
开发者ID:mgm-tp,项目名称:jfunk,代码行数:10,代码来源:WebDriverTool.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaskTracker类代码示例发布时间:2022-05-22
下一篇:
Java PreemptionMessagePBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap