Menu
  • HOME
  • TAGS

How to locate element inside css footer

html,css,ruby,watir,page-object-gem

To locate the ok use: footer .app-txt To locate the oops use: .meta .app-txt footer .app-txt {color: red;} .meta .app-txt {color: orange;} <footer> <div class="application" style="opacity: 1;"> <div class="txt" style="background-color: transparent;"> <span class="app-txt" style="background-color: transparent;">ok</span> </div> </div> </footer> <div class="meta"> <div class="application" style="opacity: 1;"> <div class="txt" style="background-color: transparent;"> <span...

how to pass dynamic values to the page-objects when using xpath or css

ruby,watir,watir-webdriver,page-object-gem

Due to the accessors methods being created when the class is evaluated, you cannot use the accessors for elements you need to dynmically locate. For more details, you can see the feature request - Issue 203. An alternative approach is to use the page object's regular locator methods. For example,...

Cheezy's Page Object, get all text_fields defined inside Page

ruby,watir,page-object-gem

The names (:first_name, :last_name, :birth_date) are only used to generate the method names such as first_name=, last_name= and birth_date=. The name is not stored or retained for later use. That said, you could iterate through the page's instance methods to find the text fields. The following text_fields method will: Get...

How to get text of selected option from select list without [ ] brackets

ruby,watir,watir-webdriver,page-object-gem,rspec-expectations

It looks like this line: @sltedStudy = page.select_list_element(:id => 'cntrStudy', :frame => frame).selected_options(&:text) gives an array of text from selected options: ["SLC"] try changing your rspec to this: expect(page.cell_element(:xpath => "//td[.='Lorem Ipsum']/following-sibling::td[1]", :frame => frame).text).to be == @sltedStudy.first or this: expect([page.cell_element(:xpath => "//td[.='Lorem Ipsum']/following-sibling::td[1]", :frame => frame).text]).to be == @sltedStudy...

How to click on a div using page_objects gem?

ruby,watir-webdriver,pageobjects,page-object-gem

Div elements do not usually need to be clicked, which is why the page object accessor creates a membership method to return the div text rather than click it. To click it, you can directly call the click method: membership_element.click ...

Access to page methods within section

ruby,watir-webdriver,page-object-gem

It seems like a bug and should be raised as an issue for the project (https://github.com/cheezy/page-object/issues). In the short term, you could work around the issue by calling wait_until directly against the Watir::Browser, which is returned by the page object's browser method: browser.wait_until { login_button? }...

Need to fire an event after entering text in a text_field

watir-webdriver,page-object-gem

That type of behaviour often is often triggered by an 'onblur' event. You can manually trigger this use the page object element's fire_event method. def enter_my_info(data) self.txtinput = data self.txtinput_element.fire_event('onblur') end If that does not work, you could try mimicking the user behaviour and input a tab character. You can...

Get the actual value of a boolean attribute

ruby,page-object-gem,rspec3,rspec-expectations

The Page-Object gem's attribute method does not do any formatting of the attribute value. It simply returns what is returned from Selenium-WebDriver (or Watir-Webdriver). In the case of boolean attributes, this means that true or false will be returned. From the Selenium-WebDriver#attribute documentation: The following are deemed to be “boolean”...

page object gem table method throwing error

page-object-gem

The problem in method #parent in FireFox 35.0. Try to use older version or use Chrome.

Trying to load a yaml file, iterate through the hash and execute some logic

ruby,selenium-webdriver,watir-webdriver,page-object-gem,pageobjects

The problem is with how the YAML file was being looped. For example, in: KBA.each do |key, value| value.each do |question, answer| end end value is a hash, so the question and answer would not be the expected values. They will actually be key/value pairs. It should have been: KBA.each...

expected one of [String, Regexp], got 1:Fixnum (TypeError) in page-object

ruby,selenium,watir-webdriver,page-object-gem

Based on the exception message, it is coming from Watir-Webdriver's ElementLocator: VALID_WHATS = [String, Regexp] def check_type(how, what) case how when :index unless what.kind_of?(Fixnum) raise TypeError, "expected Fixnum, got #{what.inspect}:#{what.class}" end else unless VALID_WHATS.any? { |t| what.kind_of? t } raise TypeError, "expected one of #{VALID_WHATS.inspect}, got #{what.inspect}:#{what.class}" end end end...

How can i iterate data through yml file until last data?

ruby,selenium-webdriver,yaml,watir-webdriver,page-object-gem

To iterate over a few arrays at once, you can use zip: def enter_data(doc) names, cities, checks = doc['samplepage'].values names.zip(cities, checks).each do |name, city, check| self.sample_name = name # related data self.sample_city = city # related data self.check = check # related data add # added it end submit end...

Cleaning up massive amount of PageObject elements

ruby,refactoring,page-object-gem

I don't see why you wouldn't keep the elements in the page object class. That's kind of the point of the class, right? If they're shared across multiple pages, then I understand putting them in a module and mixing in. But why abstract the unique elements on that page away...

Unable to locate nested p element

ruby-on-rails,rspec,watir,watir-webdriver,page-object-gem

In the HTML, the element with class "tile" is actually a p element: <p class="tile">Text: Kids </p> As a result, you need to locate it using the paragraph_element method instead of the div_element method: div(:my_title) { div_element(:class => 'con-head').paragraph_element(:class => 'tile') } ...

Accessing a nested element 3 levels deep using page objects

ruby,watir,watir-webdriver,page-object-gem,pageobjects

Assuming that the nesting is always the same, rather than having the :scar_first_name_error map through each ancestor, you could define each element with respect to its parent (or ancestor). Let us assume the HTML is: <html> <body> <div class="validate-method"> <div class="service-info"> <div class="input-group"> <div class="input-container input-left-half round"> text </div> </div>...

Can't execute 'onclick' using 'fire_event'

ruby,cucumber,watir,watir-webdriver,page-object-gem

When you use fire_event, you don't give status, but action. page.spnMngUsers_element.fire_event('click') ...

Use page-object gem to check a box in a table

watir,watir-webdriver,pageobjects,page-object-gem

You can use a plural version of your element name to get an array of matching elements. So define something generic enough to capture all your checkboxes, and then create a method to tick the correct number of them. I haven't tested this but I think it would look something...

How to test if page_url is correct using the 'page-object' gem in Ruby

ruby,watir-webdriver,page-object-gem

A page object has two methods related to getting the URL: page_url_value - This is the URL specified in the page_url accessor (ie the expected URL). current_url - This is the browser's current URL. To check that the correct page is displayed, then you want to check the current_url. The...

Get table cell content based on content of cell in neighbourhood

ruby,cucumber,page-object-gem

You could use an XPath with the following-sibling axis to find the values of adjacent cells. For example, the following page object has a method that will find the label cell based on its text. From there, navigate to the next td element, which should be the associated value. class...

RSpec expectations check CSS attribute

ruby,watir,watir-webdriver,page-object-gem,rspec-expectations

In Watir-Webdriver, the Element#style method can be used to get an element's computed style. The computed style is the element's appearance based on style sheets and their style attribute. Assuming the HTML is like: <html> <head> <style> .MenuItem { background-color: #c0c0c0; } </style> </head> <body> <table> <tr> <td class="MenuItem">menu</td> </tr>...

Watir: How I can click button in IE popup windows

ruby,cucumber,watir,watir-webdriver,page-object-gem

As best as I can tell you have two separate issues. Firstly, I have no idea how you set your browser variable to a page object instance. The Page Object Module definitely sets browser as a readable attribute. So if the code is within a class that has import PageObject,...

Create PageObject elements inside a function

ruby,rubygems,watir-webdriver,page-object-gem

Your method should looks like this: def create_element(x) div_element(:id => "something-#{x}") end Method #div is Accessor. It only defines methods for you. It's been desigened to be used in the field of a class....

How can page-object-gem be used with IRB?

ruby,selenium-webdriver,watir-webdriver,page-object-gem

Looking at their basic usage docs, it seems like calling table :groupsList, id: 'manage-groups-list' generates an instance method rather than a class method. So you would need to call the generated method like so: b = Watir::Browser.new :chrome page = ManageGroupsPage.new(b) # build a new page object page.groupsList # call...

Validate table for empty cells

cucumber,watir,watir-webdriver,page-object-gem,rspec-expectations

The one thing I do not like about manually writing a loop to iterate through and validate each cell is that you only see the result of the first failure. If there are say two cells that are blank, the test failure will only show one. As a result, I...

Check is option selected in drop down list?

ruby,watir,watir-webdriver,page-object-gem,rspec-expectations

Assuming that the sltMembers_element method is the one generated by the select_list accessor, then the page-object will have 5 methods: sltMembers returns the currently selected item text. sltMembers= selects an item. sltMembers_element returns the page-object element. sltMembers? checks if the element is present. sltMembers_options gets an array of all available...