lambdatest-selenium-driver 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 64e371a10c2acdcba047967ea3d939fad1cc669900c2a5f0728f9d3d79f91851
4
+ data.tar.gz: 7f383746e032a99bf4a79589c6ba169111d5442280ae18be64bae30022f720f7
5
+ SHA512:
6
+ metadata.gz: d60b7f7663abc7640e5957bb7619603bfee3d2b723a387124ffffbb3b6b47e32ae69094f22445f9062876fc5b6df7f1b1ef13be89bcec3f0ef8909e53e9c9d76
7
+ data.tar.gz: f4c9f34077cb225a5e4f7d95988d649a4a49da1e083c815922d8913633d9de3d47a81393fd047a694f8e252fb5db32591162c31d48a91676b5ef8078fdc74ac9
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-12-28
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Lambdatest::Selenium::Driver
2
+
3
+ ## Development
4
+
5
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
6
+
7
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
8
+
9
+ ## Contributing
10
+
11
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lambdatest-selenium-driver. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lambdatest-selenium-driver/blob/master/CODE_OF_CONDUCT.md).
12
+
13
+ ## License
14
+
15
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
16
+
17
+ ## Code of Conduct
18
+
19
+ Everyone interacting in the Lambdatest::Selenium::Driver project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lambdatest-selenium-driver/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/lambdatest/selenium/driver/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "lambdatest-selenium-driver"
7
+ spec.version = Lambdatest::Selenium::Driver::VERSION
8
+ spec.authors = ["LambdaTest"]
9
+ spec.email = ["key@lambdatest.com"]
10
+
11
+ spec.summary = "Ruby Selenium Driver"
12
+ spec.description = "Ruby Selenium SDK for testing with Smart UI"
13
+ spec.homepage = "https://www.lambdatest.com"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/LambdaTest/lambdatest-ruby-sdk"
19
+ spec.metadata["changelog_uri"] = "https://github.com/LambdaTest/lambdatest-ruby-sdk/lambdatest-selenium-driver/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[sig/ bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+ spec.add_development_dependency 'lambdatest-sdk-utils', '>= 1.0.2'
36
+
37
+ # For more information and examples about making a new gem, check out our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lambdatest
4
+ module Selenium
5
+ module Driver
6
+ VERSION = "1.0.0".freeze
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ require "lambdatest/sdk/utils"
3
+
4
+ module Lambdatest
5
+ module Selenium
6
+ module Driver
7
+ @pkg_name = "ruby-selenium-driver"
8
+ @logger = Lambdatest::Sdk::Utils.get_logger(pkg_name)
9
+
10
+ def self.smartui_snapshot(driver , snapshot_name, options = {})
11
+ if snapshot_name.nil? || snapshot_name.empty?
12
+ raise StandardError, "The `snapshotName` argument is required."
13
+ end
14
+
15
+ if driver.nil?
16
+ raise StandardError, "The `driver` argument is required."
17
+ end
18
+
19
+ if !Lambdatest::Sdk::Utils.is_smartui_enabled?
20
+ raise StandardError, "Cannot find SmartUI server."
21
+ end
22
+
23
+ begin
24
+ response = JSON.parse(Lambdatest::Sdk::Utils.fetch_dom_serializer)
25
+ driver.execute_script(response["data"]["dom"])
26
+
27
+ # Serialize and capture the DOM
28
+ snapshot = driver.execute_script("return {
29
+ 'dom' : SmartUIDOM.serialize(#{options.to_json}),
30
+ 'url' : document.URL
31
+ }")
32
+
33
+ # Post the dom to smartui endpoint
34
+ snapshot['name'] = snapshot_name
35
+ snapshot_reponse = Lambdatest::Sdk::Utils.post_snapshot(snapshot,pkg_name,options)
36
+
37
+ res = JSON.parse(snapshot_reponse)
38
+ if res && res['data'] && res['data']['warnings'] && res['data']['warnings'].length != 0
39
+ res['data']['warnings'].each do |warning|
40
+ @logger.warn(warning)
41
+ end
42
+ end
43
+
44
+ @logger.info("Snapshot captured #{snapshot_name}")
45
+ rescue => exception
46
+ @logger.error("SmartUI snapshot failed #{snapshot_name}")
47
+ @logger.error("#{exception.message}")
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lambdatest-selenium-driver
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - LambdaTest
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lambdatest-sdk-utils
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.2
27
+ description: Ruby Selenium SDK for testing with Smart UI
28
+ email:
29
+ - key@lambdatest.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lambdatest-selenium-driver.gemspec
40
+ - lib/lambdatest/selenium/driver.rb
41
+ - lib/lambdatest/selenium/driver/version.rb
42
+ homepage: https://www.lambdatest.com
43
+ licenses:
44
+ - MIT
45
+ metadata:
46
+ homepage_uri: https://www.lambdatest.com
47
+ source_code_uri: https://github.com/LambdaTest/lambdatest-ruby-sdk
48
+ changelog_uri: https://github.com/LambdaTest/lambdatest-ruby-sdk/lambdatest-selenium-driver/CHANGELOG.md
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.6.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.5.3
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Ruby Selenium Driver
68
+ test_files: []