org.openqa.selenium.support.FindBy.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.openqa.selenium.support.FindBy.<init>()方法的一些代码示例,展示了FindBy.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FindBy.<init>()方法的具体详情如下:
包路径:org.openqa.selenium.support.FindBy
类名称:FindBy
方法名:<init>

FindBy.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-security

public static class HomePage {
  private WebDriver driver;
  @FindBy(tagName = "body")
  WebElement body;
  public HomePage(WebDriver driver) {
    this.driver = driver;
  }
  public void assertAt() {
    assertThat(this.body.getText()).isEqualToIgnoringWhitespace("ok");
  }
  static <T> T to(WebDriver driver, Class<T> page) {
    driver.get("http://localhost/");
    return PageFactory.initElements(driver, page);
  }
}

代码示例来源:origin: spring-projects/spring-security

public static class DefaultLogoutPage {
  private WebDriver driver;
  @FindBy(css = "button[type=submit]")
  private WebElement submit;
  public DefaultLogoutPage(WebDriver webDriver) {
    this.driver = webDriver;
  }
  public DefaultLogoutPage assertAt() {
    assertThat(this.driver.getTitle()).isEqualTo("Confirm Log Out?");
    return this;
  }
  public DefaultLoginPage logout() {
    this.submit.click();
    return DefaultLoginPage.create(this.driver);
  }
  static DefaultLogoutPage to(WebDriver driver) {
    driver.get("http://localhost/logout");
    return PageFactory.initElements(driver, DefaultLogoutPage.class);
  }
}
public static class HomePage {

代码示例来源:origin: spring-projects/spring-security

public static class LoginForm {
  private WebDriver driver;
  private WebElement username;
  private WebElement password;
  @FindBy(css = "button[type=submit]")
  private WebElement submit;
  public LoginForm(WebDriver driver) {
    this.driver = driver;
  }
  public LoginForm username(String username) {
    this.username.sendKeys(username);
    return this;
  }
  public LoginForm password(String password) {
    this.password.sendKeys(password);
    return this;
  }
  public <T> T submit(Class<T> page) {
    this.submit.click();
    return PageFactory.initElements(this.driver, page);
  }
}

代码示例来源:origin: spring-projects/spring-security

public static class LoginForm {
    private WebDriver driver;
    private WebElement username;
    private WebElement password;
    @FindBy(css = "button[type=submit]")
    private WebElement submit;
    public LoginForm(WebDriver driver) {
      this.driver = driver;
    }
    public LoginForm username(String username) {
      this.username.sendKeys(username);
      return this;
    }
    public LoginForm password(String password) {
      this.password.sendKeys(password);
      return this;
    }
    public <T> T submit(Class<T> page) {
      this.submit.click();
      return PageFactory.initElements(this.driver, page);
    }
  }
}

代码示例来源:origin: spring-projects/spring-security

public static class DefaultLoginPage {
  @FindBy(css = "div[role=alert]")
  private WebElement alert;

代码示例来源:origin: spring-io/initializr

@FindBy(id = "form")
private WebElement form;

代码示例来源:origin: la-team/light-admin

public class DateField extends BaseField {

  private final WebElement dateField;

  @FindBy( className = "ui-datepicker-calendar" )
  private WebElement datePicker;

  public DateField( WebElement theDateField, SeleniumContext seleniumContext ) {
    super( seleniumContext );

    this.dateField = theDateField;
  }

  public String selectDateOfCurrentMonth( String date ) {
    dateField.click();
    webDriver().waitForElementVisible( datePicker );

    datePicker.findElement( By.linkText( date ) ).click();
    webDriver().waitForElementInvisible( datePicker );

    return dateField.getAttribute( "value" );
  }
}

代码示例来源:origin: la-team/light-admin

public class TopNavigationComponent extends StaticComponent {

  @FindBy( id = "topNav" )
  private WebElement topNavigation;

  public TopNavigationComponent( SeleniumContext seleniumContext ) {
    super( seleniumContext );
  }

  public LoginPage logout() {
    findLogoutLink().click();

    return new LoginPage( seleniumContext ).get();
  }

  public boolean isLoggedIn() {
    return webDriver().isElementPresent( topNavigation.findElement( By.className( "welcome" ) ) );
  }

  private WebElement findLogoutLink() {
    return topNavigation.findElement( By.linkText( "Logout" ) );
  }
}

代码示例来源:origin: la-team/light-admin

public class NavigationMenuComponent extends StaticComponent {

  @FindBy( id = "menu" )
  private WebElement navigationMenuContainer;

  public NavigationMenuComponent( SeleniumContext seleniumContext ) {
    super( seleniumContext );
  }

  public ListViewPage navigateToDomain( Domain domain ) {
    getNavigationLink( domain.getLinkText() ).click();

    return new ListViewPage( seleniumContext, domain ).get();
  }

  public DashboardPage navigateToDashboard() {
    getNavigationLink( "Dashboard" ).click();

    return new DashboardPage( seleniumContext );
  }

  private WebElement getNavigationLink( String linkText ) {
    return navigationMenuContainer.findElement( By.linkText( linkText ) );
  }
}

代码示例来源:origin: la-team/light-admin

public class WarningDialog extends StaticComponent {

  @FindBy( id = "popup_container" )
  private WebElement container;

  @FindBy( id = "popup_ok" )
  private WebElement confirmButton;

  @FindBy( id = "popup_message" )
  private WebElement message;

  public WarningDialog( SeleniumContext seleniumContext ) {
    super( seleniumContext );
  }

  public String getMessage() {
    webDriver().waitForElementVisible( container );

    return message.getText();
  }

  public boolean isPresent() {
    return webDriver().isElementPresent( container );
  }

  public void close() {
    confirmButton.click();
  }
}

代码示例来源:origin: la-team/light-admin

public class DashboardStatisticsComponent extends StaticComponent {
  @FindBy( xpath = "//table[@id='dashboard-statistics']" )
  private WebElement statisticsTable;

代码示例来源:origin: la-team/light-admin

public class BreadcrumbsComponent extends StaticComponent {
  @FindBy( xpath = "//ul[@id='breadcrumb']" )
  private WebElement breadcrumbsContainer;

代码示例来源:origin: la-team/light-admin

public class DeletionDialog extends StaticComponent {
  @FindBy( id = "popup_container" )
  private WebElement container;
  @FindBy( id = "popup_ok" )
  private WebElement confirmButton;
  @FindBy( id = "popup_cancel" )
  private WebElement cancelButton;

代码示例来源:origin: la-team/light-admin

public class FilterFormComponent extends StaticComponent {
  @FindBy( id = "filter-header")
  WebElement filerHeader;
  @FindBy( name = "filter-form")
  WebElement filterForm;
  @FindBy( id = "apply-filter")
  WebElement searchButton;
  @FindBy( id = "reset-filter")
  WebElement resetButton;

代码示例来源:origin: TEAMMATES/teammates

public class InstructorCourseStudentDetailsViewPage extends AppPage {

  @FindBy (id = "studentemail")
  private WebElement studentEmail;

  public InstructorCourseStudentDetailsViewPage(Browser browser) {
    super(browser);
  }

  @Override
  protected boolean containsExpectedPageContents() {
    return getPageSource().contains("Enrollment Details");
  }

  public void verifyIsCorrectPage(String email) {
    assertTrue(containsExpectedPageContents());
    assertEquals(email, studentEmail.getText());
  }

}

代码示例来源:origin: TEAMMATES/teammates

public class InstructorCourseEnrollResultPage extends AppPage {

  @FindBy(id = "edit_enroll")
  private WebElement editLink;

  public InstructorCourseEnrollResultPage(Browser browser) {
    super(browser);
  }

  @Override
  protected boolean containsExpectedPageContents() {
    // Intentional check for opening h1 and not closing h1 because the following content is not static
    return getPageSource().contains("<h1>Enrollment Results for");
  }

  public InstructorCourseEnrollPage clickEditLink() {
    click(editLink);
    waitForPageToLoad();
    return changePageType(InstructorCourseEnrollPage.class);
  }

}

代码示例来源:origin: appium/java-client

public class DefaultFindByWidget extends DefaultStubWidget {

  @FindBy(id = "SOME_SUB_LOCATOR")
  private DefaultFindByWidget singleWidget;

  @FindBy(id = "SOME_SUB_LOCATOR")
  private List<DefaultFindByWidget> multipleWidgets;

  protected DefaultFindByWidget(WebElement element) {
    super(element);
  }

  @Override
  public DefaultFindByWidget getSubWidget() {
    return singleWidget;
  }

  @Override
  public List<DefaultFindByWidget> getSubWidgets() {
    return multipleWidgets;
  }
}

代码示例来源:origin: TEAMMATES/teammates

public class StudentCourseJoinConfirmationPage extends AppPage {
  @FindBy(id = "button_confirm")
  private WebElement confirmButton;
  @FindBy(id = "button_cancel")
  private WebElement cancelButton;

代码示例来源:origin: TEAMMATES/teammates

@FindBy(id = "moderationHintButton")
private WebElement moderationHintButton;
@FindBy(id = "moderationHint")
private WebElement moderationHint;

代码示例来源:origin: TEAMMATES/teammates

public class InstructorCourseEnrollPage extends AppPage {
  @FindBy(id = "enrollstudents")
  private WebElement enrollTextBox;
  @FindBy(id = "button_enroll")
  private WebElement enrollButton;

相关文章