Bladeren bron

change folders

鄭中嘉 4 jaren geleden
bovenliggende
commit
12ff406cf5

+ 0 - 1
.rspec

@@ -1 +0,0 @@
---require spec_helper

+ 0 - 17
Gemfile

@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-source "https://rubygems.org"
-
-git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
-
-# gem "rails"
-
-gem "rspec", "~> 3.9"
-
-gem "faraday", "~> 1.0"
-
-gem "json", "~> 2.3"
-
-gem "selenium-webdriver", "~> 3.142"
-
-gem "pry", "~> 0.12.2"

+ 0 - 44
Gemfile.lock

@@ -1,44 +0,0 @@
-GEM
-  remote: https://rubygems.org/
-  specs:
-    childprocess (3.0.0)
-    coderay (1.1.2)
-    diff-lcs (1.3)
-    faraday (1.0.0)
-      multipart-post (>= 1.2, < 3)
-    json (2.3.0)
-    method_source (0.9.2)
-    multipart-post (2.1.1)
-    pry (0.12.2)
-      coderay (~> 1.1.0)
-      method_source (~> 0.9.0)
-    rspec (3.9.0)
-      rspec-core (~> 3.9.0)
-      rspec-expectations (~> 3.9.0)
-      rspec-mocks (~> 3.9.0)
-    rspec-core (3.9.1)
-      rspec-support (~> 3.9.1)
-    rspec-expectations (3.9.0)
-      diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.9.0)
-    rspec-mocks (3.9.1)
-      diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.9.0)
-    rspec-support (3.9.2)
-    rubyzip (2.2.0)
-    selenium-webdriver (3.142.7)
-      childprocess (>= 0.5, < 4.0)
-      rubyzip (>= 1.2.2)
-
-PLATFORMS
-  ruby
-
-DEPENDENCIES
-  faraday (~> 1.0)
-  json (~> 2.3)
-  pry (~> 0.12.2)
-  rspec (~> 3.9)
-  selenium-webdriver (~> 3.142)
-
-BUNDLED WITH
-   2.1.4

python_selenium/page_login.py → page_login.py


python_selenium/page_main.py → page_main.py


python_selenium/page_official.py → page_official.py


python_selenium/page_sign_and_send_assign.py → page_sign_and_send_assign.py


python_selenium/page_sign_and_send_prepare.py → page_sign_and_send_prepare.py


python_selenium/page_task.py → page_task.py


BIN
python_selenium/.DS_Store


BIN
spec/.DS_Store


BIN
spec/controller/.DS_Store


BIN
spec/controller/PDF_Files/test.pdf


+ 0 - 58
spec/controller/sign_yourself_spec.rb

@@ -1,58 +0,0 @@
-require 'pry'
-require 'rspec'
-require 'selenium-webdriver'
-require_relative '../page_objects/login_page'
-require_relative '../page_objects/abstract_page'
-
-describe 'Testing sign_yourself' do
-
-    wait = Selenium::WebDriver::Wait.new(timeout: 60)
-    app = nil
-
-    before(:each) do
-        app = AbstractPage.new(Selenium::WebDriver.for :chrome)
-    end
-
-    after(:each) do
-        app.quit
-    end
-    
-    it 'will go through SignYourself and this should be successful' do
-        app
-        .navigate_to_login_page              #Cause Navigation
-            .fillin_email("eric.cheng@kdanmobile.com")
-            .click_btn_after_filling_email
-            .fillin_password("ratherwoman5796",wait)
-            .click_btn_after_filling_password #Cause Navigation
-                .click_purple_circle(wait)
-                .click_sign_yourself(wait)  #Cause Navigation
-                    .upload_pdf_file(wait)
-                    .click_next_step        #Cause Navigation
-                        .assign_name(wait)
-                        .assign_time(wait)
-                        .assign_text(wait)
-                        .assign_checkbox(wait)
-                        .assign_radio_btn(wait)
-                        .click_next_step
-                        .comfirm_create_document(wait) #Cause Navigation
-                            .back_main_page(wait)      #Cause Navigation
-                                .click_completed_page(wait)
-                                .click_newest_document(wait) #Cause Navigation
-                                    .take_screenshot_and_notify("Task 1: Sign Yourself","SUCCESS")
-    end
-    
-    # it "will go through GetSignature and it will be successful" do
-    #     app
-    #     .navigateToLoginPage              #Cause Navigation
-    #         .fillInEmail("eric.cheng@kdanmobile.com")
-    #         .clickBtnAfterFillingEmail
-    #         .fillInPassword("ratherwoman5796",wait)
-    #         .clickBtnAfterFillingPassword #Cause Navigation
-    #             .clickPurpleCircle(wait)
-    #             .clickGetSignature(wait)  #Cause Navigation  #Here's the difference.
-    #                 .uploadPdfFile(wait)
-    #                 .clickNextStep        #Cause Navigation
-
-        
-    # end
-end

+ 0 - 35
spec/page_objects/abstract_page.rb

@@ -1,35 +0,0 @@
-require 'rspec'
-require 'selenium-webdriver'
-require '../support/mattermost_notifier'
-require_relative './login_page'
-
-class AbstractPage
-
-    @@driver = nil
-
-    def initialize(driver)
-        @@driver = driver
-    end
-
-    # this link will indeed take us to the login page no worries
-    def navigate_to_login_page
-        @@driver.navigate.to "https://www.dottedsign.com/zh-tw/tasks"
-        return LoginPage.new(@@driver)
-    end
-
-    def navigate_to_main_page
-        @@driver.navigate.to "https://www.dottedsign.com/zh-tw/tasks"
-        return MainPage.new(@@driver)
-    end
-
-    def take_screenshot_and_notify(taskname,status)
-        @@driver.save_screenshot(taskname+".png")
-        link = @@driver.current_url
-        MattermostNotifier.review_message("|"+taskname+"|"+status+"|"+link+"|\n")
-        return 0
-    end
-
-    def quit
-        @@driver.quit
-    end
-end

+ 0 - 78
spec/page_objects/assign_page.rb

@@ -1,78 +0,0 @@
-require_relative './abstract_page'
-require_relative './finish_task_page'
-
-class AssignPage < AbstractPage
-
-    def initialize(driver)
-        super(driver)
-    end
-
-    def find_assigned_elements(wait)
-        wait.until { @@driver.find_element(:class => "dlziMd") }
-        array = @@driver.find_elements(class: "dlziMd")
-        return array
-    end
-
-    def assign_name(wait)
-        elements = find_assigned_elements(wait)
-        elements[0].click        
-        wait.until { @@driver.find_element(:class => "bugmmO") }
-        @@driver.find_element(class: "bugmmO").click
-        wait.until { @@driver.find_element(:class => "cXKOsV") }
-        @@driver.find_element(class: "cXKOsV").click
-        @@driver.action.move_to_location(500, 350).perform
-        @@driver.action.click.perform
-        return AssignPage.new(@@driver)
-    end
-
-    def assign_time(wait)
-        elements = find_assigned_elements(wait)
-        elements[1].click
-        wait.until { @@driver.find_element(:class => "MoOOc") }
-        @@driver.find_element(class: "MoOOc").click
-        wait.until { @@driver.find_element(:class => "cXKOsV") }
-        @@driver.find_element(class: "cXKOsV").click
-        @@driver.action.move_to_location(500, 275).perform
-        @@driver.action.click.perform
-        return AssignPage.new(@@driver)
-    end
-
-    def assign_text(wait)
-        elements = find_assigned_elements(wait)
-        elements[2].click
-        wait.until { @@driver.find_element(:class => "kObcii") }
-        @@driver.find_element(class: "kObcii").send_keys("Text 測試文字")
-        wait.until { @@driver.find_element(:class => "cXKOsV") }
-        @@driver.find_element(class: "cXKOsV").click
-        @@driver.action.move_to_location(500, 200).perform
-        @@driver.action.click.perform
-        return AssignPage.new(@@driver)
-    end
-
-    def assign_checkbox(wait)
-        elements = find_assigned_elements(wait)
-        elements[3].click
-        @@driver.action.move_to_location(700, 275).perform
-        @@driver.action.click.perform
-        return AssignPage.new(@@driver)
-    end
-
-    def assign_radio_btn(wait)
-        elements = find_assigned_elements(wait)
-        elements[4].click
-        @@driver.action.move_to_location(700, 350).perform
-        @@driver.action.click.perform
-        return AssignPage.new(@@driver)
-    end
-
-    def click_next_step
-        @@driver.find_element(class: "fSImrr").click
-        return AssignPage.new(@@driver)
-    end
-
-    def comfirm_create_document(wait)
-        wait.until { @@driver.find_element(:id => "Edit-Field-Send-SignYourself") }
-        @@driver.find_element(id: "Edit-Field-Send-SignYourself").click
-        return FinishTaskPage.new(@@driver)
-    end
-end

+ 0 - 13
spec/page_objects/finish_task_page.rb

@@ -1,13 +0,0 @@
-require_relative './abstract_page'
-
-class FinishTaskPage < AbstractPage
-
-    def initialize(driver)
-        super(driver)
-    end
-
-    def back_main_page(wait)
-        sleep 40
-        navigate_to_main_page
-    end
-end

+ 0 - 30
spec/page_objects/login_page.rb

@@ -1,30 +0,0 @@
-require_relative './abstract_page'
-require_relative './main_page'
-
-class LoginPage < AbstractPage
-
-    def initialize(driver)
-        super(driver)
-    end
-
-    def fillin_email(email)
-        @@driver.find_element(id: "member_email").send_keys(email)
-        return LoginPage.new(@@driver)
-    end
-
-    def click_btn_after_filling_email
-        @@driver.find_element(class: "login100-form-btn").click
-        return LoginPage.new(@@driver)
-    end
-
-    def fillin_password(password,wait)
-        wait.until {@@driver.find_element(id:'member_password').displayed?}
-        @@driver.find_element(id: "member_password").send_keys(password)
-        return LoginPage.new(@@driver)
-    end
-
-    def click_btn_after_filling_password
-        @@driver.find_element(id: "btn-ready-send").click
-        return MainPage.new(@@driver)
-    end
-end

+ 0 - 45
spec/page_objects/main_page.rb

@@ -1,45 +0,0 @@
-require_relative './abstract_page'
-require_relative './upload_page'
-require_relative './finish_task_page'
-
-class MainPage < AbstractPage
-
-    def initialize(driver)
-        super(driver)
-    end
-
-    def click_purple_circle(wait)
-        wait.until {@@driver.find_element(class: "sc-hRmvpr").displayed?}
-        @@driver.find_element(class: "sc-hRmvpr").click
-        return MainPage.new(@@driver)
-    end
-
-    def click_sign_yourself(wait)
-        wait.until {@@driver.find_element(id: "Task-AddTask-SignYourself").displayed?}
-        @@driver.find_element(id: "Task-AddTask-SignYourself").click
-        return UploadPage.new(@@driver)
-    end
-
-    def click_completed_page(wait)
-        wait.until {@@driver.find_element(class: "hrNFwS").displayed?}
-        tabs = @@driver.find_elements(class: "hrNFwS")
-        tabs[2].click
-        return MainPage.new(@@driver)
-    end
-
-    def click_newest_document(wait)
-        wait.until { @@driver.find_element(:class => "geNFaQ") }
-        @@driver.find_element(class: "geNFaQ").click
-        sleep 15
-        return FinishTaskPage.new(@@driver)
-    end
-
-    # GetSignature starts from here
-    def click_get_signature(wait)
-        wait.until {@@driver.find_element(id: "Task-AddTask-GetSignatures").displayed?}
-        @@driver.find_element(id: "Task-AddTask-GetSignatures").click
-        return UploadPage.new(@@driver)
-    end
-
-
-end

+ 0 - 21
spec/page_objects/upload_page.rb

@@ -1,21 +0,0 @@
-require_relative './abstract_page'
-require_relative './assign_page'
-
-class UploadPage < AbstractPage
-
-    def initialize(driver)
-        super(driver)
-    end
-
-    def upload_pdf_file(wait)
-        wait.until { @@driver.find_element(:css => "input[type=file]") }
-        element = @@driver.find_element(css: 'input[type=file]')
-        element.send_keys "/Users/kdanuser/Desktop/github/QA-Ruby-Selenium/spec/controller/PDF_Files/test.pdf"
-        return UploadPage.new(@@driver)
-    end
-
-    def click_next_step
-        @@driver.find_element(class: 'fSImrr').click
-        return AssignPage.new(@@driver)
-    end
-end

+ 0 - 100
spec/spec_helper.rb

@@ -1,100 +0,0 @@
-# This file was generated by the `rspec --init` command. Conventionally, all
-# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
-# The generated `.rspec` file contains `--require spec_helper` which will cause
-# this file to always be loaded, without a need to explicitly require it in any
-# files.
-#
-# Given that it is always loaded, you are encouraged to keep this file as
-# light-weight as possible. Requiring heavyweight dependencies from this file
-# will add to the boot time of your test suite on EVERY test run, even for an
-# individual file that may not need all of that loaded. Instead, consider making
-# a separate helper file that requires the additional dependencies and performs
-# the additional setup, and require it from the spec files that actually need
-# it.
-#
-# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
-RSpec.configure do |config|
-  # rspec-expectations config goes here. You can use an alternate
-  # assertion/expectation library such as wrong or the stdlib/minitest
-  # assertions if you prefer.
-  config.expect_with :rspec do |expectations|
-    # This option will default to `true` in RSpec 4. It makes the `description`
-    # and `failure_message` of custom matchers include text for helper methods
-    # defined using `chain`, e.g.:
-    #     be_bigger_than(2).and_smaller_than(4).description
-    #     # => "be bigger than 2 and smaller than 4"
-    # ...rather than:
-    #     # => "be bigger than 2"
-    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
-  end
-
-  # rspec-mocks config goes here. You can use an alternate test double
-  # library (such as bogus or mocha) by changing the `mock_with` option here.
-  config.mock_with :rspec do |mocks|
-    # Prevents you from mocking or stubbing a method that does not exist on
-    # a real object. This is generally recommended, and will default to
-    # `true` in RSpec 4.
-    mocks.verify_partial_doubles = true
-  end
-
-  # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
-  # have no way to turn it off -- the option exists only for backwards
-  # compatibility in RSpec 3). It causes shared context metadata to be
-  # inherited by the metadata hash of host groups and examples, rather than
-  # triggering implicit auto-inclusion in groups with matching metadata.
-  config.shared_context_metadata_behavior = :apply_to_host_groups
-
-# The settings below are suggested to provide a good initial experience
-# with RSpec, but feel free to customize to your heart's content.
-=begin
-  # This allows you to limit a spec run to individual examples or groups
-  # you care about by tagging them with `:focus` metadata. When nothing
-  # is tagged with `:focus`, all examples get run. RSpec also provides
-  # aliases for `it`, `describe`, and `context` that include `:focus`
-  # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
-  config.filter_run_when_matching :focus
-
-  # Allows RSpec to persist some state between runs in order to support
-  # the `--only-failures` and `--next-failure` CLI options. We recommend
-  # you configure your source control system to ignore this file.
-  config.example_status_persistence_file_path = "spec/examples.txt"
-
-  # Limits the available syntax to the non-monkey patched syntax that is
-  # recommended. For more details, see:
-  #   - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
-  #   - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
-  #   - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
-  config.disable_monkey_patching!
-
-  # This setting enables warnings. It's recommended, but in some cases may
-  # be too noisy due to issues in dependencies.
-  config.warnings = true
-
-  # Many RSpec users commonly either run the entire suite or an individual
-  # file, and it's useful to allow more verbose output when running an
-  # individual spec file.
-  if config.files_to_run.one?
-    # Use the documentation formatter for detailed output,
-    # unless a formatter has already been configured
-    # (e.g. via a command-line flag).
-    config.default_formatter = "doc"
-  end
-
-  # Print the 10 slowest examples and example groups at the
-  # end of the spec run, to help surface which specs are running
-  # particularly slow.
-  config.profile_examples = 10
-
-  # Run specs in random order to surface order dependencies. If you find an
-  # order dependency and want to debug it, you can fix the order by providing
-  # the seed, which is printed after each run.
-  #     --seed 1234
-  config.order = :random
-
-  # Seed global randomization in this process using the `--seed` CLI option.
-  # Setting this allows you to use `--seed` to deterministically reproduce
-  # test failures related to randomization by passing the same `--seed` value
-  # as the one that triggered the failure.
-  Kernel.srand config.seed
-=end
-end

+ 0 - 39
spec/support/mattermost_notifier.rb

@@ -1,39 +0,0 @@
-require "../support/requester"
-require "time"
-
-
-class MattermostNotifier
-  class << self
-    def review_message(results)
-      color_map = {
-        1 => 'danger',
-        2 => '#ff4500',
-        3 => 'warning',
-        4 => '#9acd32',
-        5 => 'good',
-      }
-
-      text = "|QA_Test|Status: Mac Web, #{Time.now.strftime('%Y-%m-%d_%H.%M.%S')}|Link|\n"
-      text+= "|:---|:---|:---|\n"
-      text+= results
-
-      content = {
-        attachments: [
-          {
-            color: color_map[5],
-            text: text
-          }
-        ]
-      }
-      #find which channel should go
-      publish(content, "/hooks/d8i7w5sktfr5i864bcqsc8ieto")
-    end
-
-    private
-    def publish(message_content, path)
-      host = Requester.new('http://chat.kdanmobile.com')
-      host.json_send(:post, path, message_content)
-    end
-    
-  end
-end

+ 0 - 48
spec/support/requester.rb

@@ -1,48 +0,0 @@
-require "faraday"
-require "json"
-
-class Requester
-  attr_reader :host, :conn
-
-  def initialize(host, options={})
-    @host = host
-    @conn = init_conn
-  end
-
-  def json_send(http_method, path, params={}, headers={})
-    res = @conn.send(http_method) do |req|
-      req.url path
-      req.headers['Content-Type'] = 'application/json'
-      req.body = params.to_json
-    end
-    process_response(res)
-  rescue => e
-    error_response(e)
-  end
-
-  private
-
-  def init_conn()
-    Faraday.new(url: host, ssl: nil) do |faraday|
-      faraday.request  :url_encoded             # form-encode POST params
-      faraday.response :logger                  # log requests to $stdout
-      faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
-    end
-  end
-
-  def process_response(response)
-    result = {'status' => response.status}
-    begin
-      body = Oj.load(response.body)
-      body = body.is_a?(Hash) ? body : {'body' => body}
-      body['body_status'] = body.delete('status') unless body['status'].is_a?(Integer)
-    rescue
-      body = {'body' => response.body}
-    end
-    result.merge(body)
-  end
-
-  def error_response(err)
-    {'status' => 500, 'message' => "#{err.class.name}: #{err.message}"}
-  end
-end

python_selenium/test_sign_yourself.py → test_sign_yourself.py