pageobjects

Canonical way to define page objects in Protractor

余生颓废 提交于 2019-11-30 22:36:12
问题 We've been using the Page Object pattern for quite a while. It definitely helps to organize the end-to-end tests and makes tests more readable and clean. As Using Page Objects to Organize Tests Protractor documentation page shows us, we are defining every page object as a function and use new to "instantiate" it: "use strict"; var HeaderPage = function () { this.logo = element(by.css("div.navbar-header img")); } module.exports = HeaderPage; Usage: "use strict"; var HeaderPage = require("./..

Codeception, write acceptance tests with the pageObject design pattern and gherkin

拜拜、爱过 提交于 2019-11-30 16:57:56
I'm looking for a simple example of code with the pageObject design pattern and gherkin because when I follow the codeception BDD documentation , all examples written in the tests/ support/AcceptanceTester.php. I don't understand (poor english skills - -) how not concentrate all code in the AcceptanceTester.php file. By example, I have a sample home page with two buttons A and B. If the user click on the button A, the page A is loaded else if the user click on button B, the page B is loaded. Currently, my AcceptanceTester : <?php // tests/_support/AcceptanceTester.php /** * Inherited Methods *

Selenium Webdriver: Page factory initialization using paths relative to other elements?

十年热恋 提交于 2019-11-30 14:12:03
I'm trying to write a page object in Selenium Webdriver using the page factory @FindBy annotations. The page object is for a sidebar, and the parent WebElement containing all elements the page object needs to interact with is initialized in this way: @FindBy (xpath = "//div[contains(@class,'yui3-accordion-panel-content') and child::div[.='Sidebar']]") WebElement sidebar; I then want the search input relative to this sidebar element. Is there a way to do this referencing sidebar element? I could copy and paste the entire path to the beginning: @FindBy (xpath = "//div[contains(@class,'yui3

Multiple browsers and the Page Object pattern

左心房为你撑大大i 提交于 2019-11-30 08:37:16
We are using the Page Object pattern to organize our internal AngularJS application tests. Here is an example page object we have: var LoginPage = function () { this.username = element(by.id("username")); this.password = element(by.id("password")); this.loginButton = element(by.id("submit")); } module.exports = LoginPage; In a single-browser test, it is quite clear how to use it: var LoginPage = require("./../po/login.po.js"); describe("Login functionality", function () { var scope = {}; beforeEach(function () { browser.get("/#login"); scope.page = new LoginPage(); }); it("should successfully

Get the By locator of an already found WebElement

此生再无相见时 提交于 2019-11-30 08:21:16
Is there an elegant way to get the By locator of a Selenium WebElement, that I already found/identified? To be clear about the question: I want the "By locator" as used to find the element. I am in this case not interested in a specific attribute or a specific locator like the css-locator. I know that I could parse the result of a WebElement's toString() method: WebElement element = driver.findElement(By.id("myPreciousElement")); System.out.println(element.toString()); Output would be for example: [[FirefoxDriver: firefox on WINDOWS (....)] -> id: myPreciousElement] if you found your element

Why should I be making my page objects instantiated rather than static?

筅森魡賤 提交于 2019-11-30 05:02:41
问题 I'm a relatively new QA Engineer working on learning Selenium (in Java) and I want to use page objects to model my pages. Currently, the way I'm doing it, my page object classes are collections of static variables (By objects for locating page elements) and static methods (for getting the By objects and performing page functions). This seemed like the simplest way to me as my methods don't need to rely on any instance variables, just the locators. I just call these methods as I need them in

Get the By locator of an already found WebElement

时光怂恿深爱的人放手 提交于 2019-11-29 11:04:06
问题 Is there an elegant way to get the By locator of a Selenium WebElement, that I already found/identified? To be clear about the question: I want the "By locator" as used to find the element. I am in this case not interested in a specific attribute or a specific locator like the css-locator. I know that I could parse the result of a WebElement's toString() method: WebElement element = driver.findElement(By.id("myPreciousElement")); System.out.println(element.toString()); Output would be for

Using PageObjects, Page Factory and WebDriverWait in Selenium WebDriver using Java

隐身守侯 提交于 2019-11-29 04:36:56
I've been using Selenium WebDriver to implement functional tests for some projects that I've worked with. I'm trying to use the Page Object design pattern with Page Factory to factor out my locators. I've also created a static WaitTool object (singleton) that implements several waiting techniques with optional timeout parameters. My current problem is that I would like to use my wait methods before the PageFactory attempts to initialise the WebElements. The reason I would like to wait is because the PageFactory may try to initialise the page elements before they are available on the page. Here

How to implement WebDriver PageObject methods that can return different PageObjects

血红的双手。 提交于 2019-11-28 16:45:21
I've just started using WebDriver , and I'm trying to learn the best practices, in particular using PageObjects and PageFactory . It's my understanding that PageObjects should expose the various operations on a web page, and isolate the WebDriver code from the test class. Quite often, the same operation can result in navigating to different pages depending on the data used. For example, in this hypothetical Login scenario, providing admin credentials takes you to the AdminWelcome page, and providing Customer credentials takes you to the CustomerWelcome page. So the easiest way to implement

What's the best way to use Selenium PageObject Design Pattern

此生再无相见时 提交于 2019-11-28 15:54:46
I'm creating tests using Selenium 2 Web Driver with C#.Net. After reading through a lot of the Selenium documentation, I am left still feeling unsure on how to go about testing using the PageObject design patterns. Many of the selenium examples are only shown in Java and the API bindings for .Net are not always as similar as one would think they are due to limitations and the standards set by certain languages. What is the best way to use the PageObject design pattern with PageFactory in .Net Selenium Web Driver? Eventually, I want my PageObjects to handle more functionality, rather than my