如何使用 page-object 和 watir 生成诱惑报告

时间:2021-04-11 14:08:13

标签: ruby selenium watir allure page-object-gem

我使用了以下链接中 allure-ruby-commons 中提到的配置

https://github.com/allure-framework/allure-ruby/tree/master/allure-ruby-commons

但是我无法使用相同的方法生成诱惑报告。任何人都可以帮助我。

如何使用 watir 和 page-object gem 生成诱惑报告

require 'watir'
require 'page-object'

class GithubPage
    include PageObject

    link(:sign_in, text: /Sign in/)
    text_field(:user_id, id: 'login_field')
    text_field(:password, id: 'password')
    button(:login_btn, value: 'Sign in')
    link(:notification, href: '/notifications')
    list_items(:name_count, xpath: "//p[text()='Repositories']/following-sibling::ul/li")
    span(:select_all, text: /Select all/)
    button(:select_remaining, text: /Select all/)
    button(:done_all, css: "div[class*='notifications-mark-all-actions'] button[title='Done']")
    button(:done, css: "div[class*='notifications-mark-selected-actions'] button[title='Done']")
    h3(:no_notifications, text: 'All caught up!')

    def login(username, password)
        sign_in
        self.user_id = username
        self.password = password
        login_btn
    end

    def check_and_read_notifications
        notification_element.when_visible.click
        if no_notifications?
            puts 'There are no Notifications left'
        else
            name_count_elements.each do |name|
                puts name.text
            end
            select_all_element.click
            if select_remaining?
                select_remaining
                done_all
            else
                done
            end
            sleep 1
            notification
        end
    end

end
require_relative 'github_page.rb'
require 'allure-ruby-commons'

browser = Watir::Browser.new :chrome, headless: true
browser.window.resize_to(1920, 1080)
github = GithubPage.new(browser)

github.navigate_to 'http://github.com'
github.login('test', 'tester')
github.check_and_read_notifications

Allure.configuration

Allure.configure do |config|
    config.results_directory = "./Results"
    config.clean_results_directory = true
    config.logging_level = Logger::INFO
end

0 个答案:

没有答案