pageobjects

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

匆匆过客 提交于 2019-12-18 17:00:49
问题 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

Multiple browsers and the Page Object pattern

谁都会走 提交于 2019-12-18 13:00:52
问题 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 = {};

Selenium [Java] PageFactory Design : Where do I write my Assertions following Page Object Model

喜夏-厌秋 提交于 2019-12-18 07:22:47
问题 I am following Page Object Model to automate a flow in one application. In one of the module I have to assert Page Title and some more messages. As of now I am putting my Assertion code in the PageFactory itself as follows: public class EditPost { WebDriver driver; public EditPost(WebDriver editPostDriver) { this.driver=editPostDriver; } @FindBy(how=How.XPATH,using="//*[@id='message']/p") WebElement post_published; public void assert_message() { String actual_message_title=post_published

Pythonic way to resolve circular import statements?

孤街醉人 提交于 2019-12-17 17:37:19
问题 I just inherited some code which makes me uneasy: There is a testing library, full of classes corresponding to webpages on our site, and each webpage class has methods to automate the functionality on that page. There are methods to click the link between pages, which returns the class of the linked page. Here's a simplified example: File homePageLib.py: class HomePage(object): def clickCalendarLink(self): # Click page2 link which navigates browswer to page2 print "Click Calendar link" # Then

How to avoid Compound Class name error in Page Object?

我们两清 提交于 2019-12-17 15:51:32
问题 When I try to use the class name that having space class = "country name" in page object, I'm getting: Compound class names not permitted Selenium::WebDriver::Error::UnknownError) How can I use the class name that having space. Eg: class = "country name" 回答1: Use a CSS selector instead: .country.name The important thing to note is that this example is wrong! If "country name" is meant as a name of a country, that is. Class names can't have spaces in them. In fact, the class attribute is a

How to add explicit wait in PageFactory in PageObjectModel?

橙三吉。 提交于 2019-12-17 07:54:21
问题 I have added hardcode wait thread.sleep() in my below code. How to use explicit wait. I want to wait till "username" WebElement appear. My program is working perfectly. I have already written testcases. package com.pol.zoho.PageObjects; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.WebDriverWait; public class ZohoLoginPage { WebDriver

How to pass the same driver instance in page Object model?

五迷三道 提交于 2019-12-13 11:08:43
问题 My automation framework is using selenium + TestNG + PageObject model. Structure : My Testng class / test case : nullpointer error How can i pass the driver instance into my page objects? 回答1: I can see you are declaring a new instance of WebDriver inside the @BeforeTest method. You need to use the WebDriver instance that you declared outside the @BeforeTest i.e. you have already declared static WebDriver driver; Use the same driver inside your @BeforeTest . So inside the before method,

How can I get some particular link form the links collection

流过昼夜 提交于 2019-12-13 04:37:52
问题 I'm using watir-webdriver have several lines of the same code shown below: ... <p class="schedule-text"> by <a href="http://www.somesite.com">MarketingClub</a> in <a href="http://www.somesite2.com">Marketing</a> </p> I need to get the first links included in p tag and the second links included in p tag so using page object I've added the following code: links(:followees_category, :css => "#home-followees li.animate-in ul li[data-show-id] p.schedule-text a") ... followees_category_elements

Accessing a table within a table (Watir/PageObject)

一个人想着一个人 提交于 2019-12-13 01:15:13
问题 I'm running Watir-webdriver with Cheezy's PageObject for Cucumber testing. I am new to ruby, testing, pageobjects, and watir. I am trying to access a table. Specifically, I'm trying to click an image in the 7th column. This is my code: tables.downcase! tables.gsub!(/\s+/, '_') tables_elements = self.send("#{tables}s_elements") the_table = tables_elements[table_number] the_table[row_number][column_number].click With this code running, it becomes apparent that it believes the table (columns,

How to select from a dropdown using POM Selenium

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 22:16:06
问题 so i need to select from a drop down and all the code seems to do is highlight the value and not select it, package uk.co.brightfuture.bfslogin.selenium.page; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.Select; import uk.co.brightfuture.bfslogin.selenium.PagePath; import uk.co.brightfuture.bfslogin.selenium.PageTitle; public class