pageobjects

What's the correct Protractor's syntax for Page Objects?

这一生的挚爱 提交于 2019-12-03 15:03:37
问题 I've come across different types of syntax for Protractor's Page Objects and I was wondering, what's their background and which way is suggested. This is the official PageObject syntax from Protractor's tutorial. I like it the most, because it's clear and readable: use strict; var AngularHomepage = function() { var nameInput = element(by.model('yourName')); var greeting = element(by.binding('yourName')); this.get = function() { browser.get('http://www.angularjs.org'); }; this.setName =

Does Webdriver support pagefactory for Python?

大憨熊 提交于 2019-12-03 13:17:56
I was reading about page objects and design patterns on the Webdriver project site and came across pagefactory . It doesn't look like the Webdriver for Python API includes pagefactory. Is this true? I don't think there is any equivalents of the Java annotations (@Find(By.xxx) etc) in Python. But it doesn't mean that you can't use the PageObject pattern. You can find good example on how to do here : https://github.com/SeleniumHQ/selenium/blob/master/py/test/selenium/webdriver/common/google_one_box.py Dynamically-typed languages like Python are less obsessed by design patterns to create objects

What's the correct Protractor's syntax for Page Objects?

可紊 提交于 2019-12-03 03:49:48
I've come across different types of syntax for Protractor's Page Objects and I was wondering, what's their background and which way is suggested. This is the official PageObject syntax from Protractor's tutorial. I like it the most, because it's clear and readable: use strict; var AngularHomepage = function() { var nameInput = element(by.model('yourName')); var greeting = element(by.binding('yourName')); this.get = function() { browser.get('http://www.angularjs.org'); }; this.setName = function(name) { nameInput.sendKeys(name); }; this.getGreeting = function() { return greeting.getText(); }; }

How to initialize SelectElements while using PageFactory / FindsBy in Selenium C#?

偶尔善良 提交于 2019-12-03 00:12:55
I am building a Page Object Model in Selenium WebDriver for C#, using the PageFactory. Unfortunately, I have discovered that the FindsByAttribute will not initialize a SelectElement (HTML <select> tag / dropdown menu). I've happened upon or come up with a few ideas to work around it so far, but none of them is ideal: PageFactory and FindsByAttribute are sealed , so I can't force it to by just inheriting those. Manually instantiating a SelectElement from an IWebElement in each method is rather messy and duplicative. It also ignores the apparent built-in wait in PageFactory and throws

Why is this code throwing an output from a random other code in my project? How can I fix this?

房东的猫 提交于 2019-12-02 18:14:59
问题 I am new to Java and I might have messed up something in the code. But what is wrong here? I am trying to create objects for the elements in the home page which I have to test. package pageObjects; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class HomePage { private static WebElement element; public static void main(String args[], WebDriver driver){ HomePage hp = new HomePage(); hp.SignInButton(driver); hp.ImageButton

PageObject with Ruby - set text in a text field only works in the main file

淺唱寂寞╮ 提交于 2019-12-02 12:38:18
问题 I'm automating a site that has a page with a list of options selected by a radio button. When selecting one of the radios, a text field and a select list are presented. I created a file (test_contracting.rb) that is the one through which I execute the test (ruby test_contracting.rb) and some other classes to represent my page. On my class ContractPage, I have the following element declaration: checkbox(:option_sub_domain, :id => "option_sub_domain") text_field(:domain, :id => "domain_text")

Why is this code throwing an output from a random other code in my project? How can I fix this?

旧巷老猫 提交于 2019-12-02 08:02:42
I am new to Java and I might have messed up something in the code. But what is wrong here? I am trying to create objects for the elements in the home page which I have to test. package pageObjects; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class HomePage { private static WebElement element; public static void main(String args[], WebDriver driver){ HomePage hp = new HomePage(); hp.SignInButton(driver); hp.ImageButton(driver); System.out.println("Yup"); } public WebElement SignInButton(WebDriver driver){ element = driver

PageObject with Ruby - set text in a text field only works in the main file

安稳与你 提交于 2019-12-02 03:25:38
I'm automating a site that has a page with a list of options selected by a radio button. When selecting one of the radios, a text field and a select list are presented. I created a file (test_contracting.rb) that is the one through which I execute the test (ruby test_contracting.rb) and some other classes to represent my page. On my class ContractPage, I have the following element declaration: checkbox(:option_sub_domain, :id => "option_sub_domain") text_field(:domain, :id => "domain_text") select_list(:tld, :id => "domain_tld") I've created in the ContractPage a method that sets the

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

瘦欲@ 提交于 2019-12-01 05:44:26
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 my test code. However, everything I read about page objects talks about instantiating them and having

Canonical way to define page objects in Protractor

二次信任 提交于 2019-12-01 02:48:50
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("./../po/header.po.js"); describe("Header Look and Feel", function () { var header; beforeEach(function () {