pageobjects

How to wait for invisibility of an element through PageFactory using Selenium and Java

て烟熏妆下的殇ゞ 提交于 2019-12-12 19:25:32
问题 Is there a way to wait for an element not present in Selenium using PageFactory annotations? When using: @FindBy(css= '#loading-content') WebElement pleaseWait; to locate the element, and then: wait.until(ExpectedConditions.invisibilityOfElementLocated(pleaseWait)); I would get: org.opeqa.selenium.WebElement cannot be converted to org.openqa.selenium.By I am able to do what I need by using: wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector('loading-content'))); However

Nightwatch(PageObject) access elements from different page object

雨燕双飞 提交于 2019-12-12 18:20:31
问题 Is there a way to access elements defined in one page object file from another page object file? Example: If we need to access '@usernameInput' from LoginPage.ts file, do we need to duplicate it from HomePage.ts ? Is there any other way? HomePage.ts const page: PageObject = { url: ..., commands: [ enterUsername: (query: string) => { return this .waitForElementVisible('@usernameInput') }], elements: { usernameInput: { locateStrategy: 'xpath', selector: '//input[@name="Username"]', } };

WebDriver/PageObject/FindBy: how to specify xpath with dynamic value?

╄→гoц情女王★ 提交于 2019-12-12 11:09:23
问题 I'm trying to use Page Object pattern in Java and having some trouble with @FindBy/XPath . Earlier, I used the following construction in Groovy: driver.findElement(By.xpath("//td[contains(text(),'$SystemName')]")).click() Here, SystemName is a parameter that can be different. Now, I want to do the same thing but in accordance with Page Object paradigm in Java: public class ManagedSystems { private WebDriver driver; @FindBy(id="menu_NewSystem") private WebElement menuNewSystem; @FindBy (xpath

Where should the Page Objects be instantiated?

匆匆过客 提交于 2019-12-12 01:49:59
问题 I would like to know where should I instantiate my Page objects? Here is my project hierarchy: Pages : Contains all page objects with constructor such as public LoginPage extends BasePage { super(driver); PageFactory.initElements(driver, this); } My BasePage contains all common methods such as table handling, data gathering from webtable etc.. I have a baseTest which contains all of the Page Objects instantiation and my tests are extend this class. LoginPage loginPage = new LoginPage(driver);

using a function from Page Object in Protractor

…衆ロ難τιáo~ 提交于 2019-12-11 17:57:53
问题 I have this code in my afterEach block that works to console log the page source for a failed spec. But I want to move it to another class instead. afterEach(function () { const state = this.currentTest.state; if (state === 'failed') { browser.driver.getPageSource().then(function (res) { console.log(res); }); } }); but when i try to use the following in another class, i get 'Property 'currentTest' does not exist on type 'HelperClass'. How do i declare the currentTest property? import {

Selenium - Best Practices - Page Object Patter & Page Factory

丶灬走出姿态 提交于 2019-12-11 12:33:00
问题 I've been developing my Project since 1 year from 0. I've reached certain level of 'maintenance' of my Framework and tests. However, each day i have more doubts if i'm using good practices in my Project. Would be great if someone experienced could answer for few my questions. Mostly i have questions for Page Object Patter and Page Factory. Short description: My Project is a one-page based application written in C#, angular.js, javascript. Driver is a static instance and it has bunch of

Javascript redirects on page->open

谁说我不能喝 提交于 2019-12-11 04:14:07
问题 Using behat/mink, I'm testing the "remember me" functionality. Functionally, when the user visits the main page, javascript/ajax code verifies if the user is "remembered". If yes, then the javascripts redirects to another page. My LoginPage is defined with $path = '/login.html' - after the redirect, I will end up on /main.html . In my context, I use $loginPage->open() - however this throws exception Expected to be on "https://example.com/login.html" but found "https://example.com/main.html"

Where should I define modal specific code in Selenium Page Object Model pattern

微笑、不失礼 提交于 2019-12-11 02:44:56
问题 In Selenium Page Object model pattern web pages are represented as classes, various elements on the page are defined as variables in the class, and user interactions are implemented as methods in the class. That is for each page separate class is created. There's an ecommerce application with pages- login, home, search, product, cart, checkout, and order confirmation. There are variuos modals also, like cart preview, add customer, etc. Some modals will be visible on multiple pages and some

Selenium Page Object. How to read @FindBy locator from external source?

十年热恋 提交于 2019-12-10 15:56:06
问题 I can only use hardcoded values in page object @FindBy annotations But I would like to resolve locators dynamically. public class LoginPage extends BasePage { // hardocded value works ok @FindBy(name = "login field") WebElement usernameFld; // does not compile // this is a kind of what I would like to have @FindBy( getLocatorFromExternalSource() ) WebElement passwordFld; } I have seen a few posts mentioning that such things can be solved by implementing custom annotations/decorators/factories

Using the Page Object Model is it better practice to return a promise or to use async/await in the function when the function does not return a value

烈酒焚心 提交于 2019-12-10 15:51:11
问题 Hoping to get some feedback on what is the best practice in this situation (Protractor testing framework using page object model with async/await instead of SELENIUM_PROMISE_MANAGER) . Let say I have a function called setUsername which simply sets the username in a field. I'm wondering is it better practice to use async/await to await the action in the function itself or to return the action. Either way whenever the function is called it will need to be awaited. option1 this.setUsername =