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


Java TargetLocator类代码示例

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


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


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