Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript PageObjects are not supported #38

Closed
josepmc opened this issue Feb 1, 2017 · 2 comments
Closed

TypeScript PageObjects are not supported #38

josepmc opened this issue Feb 1, 2017 · 2 comments
Milestone

Comments

@josepmc
Copy link

josepmc commented Feb 1, 2017

Following is a snippet of a PO which won't be detected properly

import { browser, by, By, element, $, $$, protractor, ElementFinder, ExpectedConditions, ElementArrayFinder } from 'protractor';
import * as webdriver from 'selenium-webdriver';

export class MyPO extends MyAbstractPO { // This line won't be detected
  bar = 'foo'; // This will be the only line detected
  private baz : Foo = new Foo();

  constructor() {
    super();
  }

  public fubar(bar: string) { // This method won't be detected

  }

  get foobar() { //This method won't be detected

  }

  set foobaz(baz: Foo) { //This method won't be detected

  }
}
@alexkrechik
Copy link
Owner

Please advice - what elements should be detected as objects for current page?
We have some functions in our page objects pages, but I didn't include them due to no needs in our feature files. Will you use something like "page"."fubar" in your tests ?

@josepmc
Copy link
Author

josepmc commented Feb 1, 2017

Getters and Setters should be detected in my point of view. You can do MyPO.foobar is 'foo' and "I select 'bar' in MyPO.foobaz"

A far fetched example could be this:

// Features/definitions/Foo.feature
[...]
Given Bar.Name is 'foo' and Bar.Password is 'bar'

// features/PO/Bar.ts
export class Bar {
   Name = '';
   private password : string;
   set Password(pwd: String) {
      this.password = pwd;
   }
}

// Features/Steps/MySteps.steps.ts
export class MySteps {
     private po : Bar = new Bar();
     public parseAndExecuteIf(str : string) {
          // Regex (.* is .*) and execute it
     }

     @given("/(.* is .*) and (.* is .*)/")
     public foobar(username, password) {
          this.parseAndExecuteIf(username);
          this.parseAndExecuteIf(password)
     }
}

@alexkrechik alexkrechik added this to the 2.1.0 milestone Mar 19, 2017
@alexkrechik alexkrechik modified the milestones: 2.1.0, 2.2.0 Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants