Skip to content

Commit 67f720c

Browse files
committed
Sample Tests
0 parents  commit 67f720c

File tree

4 files changed

+110
-0
lines changed

4 files changed

+110
-0
lines changed

Diff for: LambdaTest.rb

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
require 'rubygems'
2+
require 'selenium-webdriver'
3+
require 'test/unit'
4+
require_relative "readConf"
5+
6+
class AdvanceTest < Test::Unit::TestCase
7+
8+
def setup
9+
config = ReadConfig.new()
10+
lt_user = ENV['LT_USERNAME']
11+
lt_appkey = ENV['LT_APPKEY']
12+
lt_os = ENV['LT_OPERATING_SYSTEM']
13+
lt_browser = ENV['LT_BROWSER']
14+
lt_browser_version = ENV['LT_BROWSER_VERSION']
15+
if(lt_user == "" || lt_user == nil)
16+
lt_user = config.getDetails('LT_USERNAME')
17+
end
18+
if(lt_appkey == "" || lt_appkey == nil)
19+
lt_appkey = config.getDetails('LT_APPKEY')
20+
end
21+
if(lt_browser == "" || lt_browser == nil)
22+
lt_browser = config.getDetails('LT_BROWSER')
23+
end
24+
if(lt_os == "" || lt_os ==nil)
25+
lt_os = config.getDetails('LT_OPERATING_SYSTEM')
26+
end
27+
if(lt_browser_version == "" || lt_browser_version == nil)
28+
lt_browser_version = config.getDetails('LT_BROWSER_VERSION')
29+
end
30+
caps = {
31+
:browserName => lt_browser,
32+
:version => lt_browser_version,
33+
:platform => lt_os,
34+
:name => "RubyRSpecTestSample",
35+
:build => "LambdaTestSampleApp",
36+
:network => true,
37+
:visual => true,
38+
:video => true,
39+
:console => true
40+
}
41+
puts (caps)
42+
@driver = Selenium::WebDriver.for(:remote,
43+
:url => "https://"+lt_user+":"+lt_appkey+"@hub.lambdatest.com/wd/hub",
44+
:desired_capabilities => caps)
45+
46+
@driver.manage.window.maximize
47+
48+
@driver.get("https://lambdatest.github.io/sample-todo-app/" )
49+
end
50+
51+
def test_Login
52+
item_name = "Yey, Lets add it to list"
53+
54+
#Click on First Checkbox
55+
fCheckbox = @driver.find_element(:name, 'li1')
56+
fCheckbox.submit
57+
58+
#Click on Second Checkbox
59+
sCheckbox = @driver.find_element(:name, 'li2')
60+
sCheckbox.submit
61+
62+
#Enter Item Name
63+
itemNameInput = @driver.find_element(:id, 'sampletodotext')
64+
itemNameInput.send_keys item_name
65+
66+
#Click on Add Button
67+
addButton = @driver.find_element(:id, 'addbutton')
68+
addButton.submit
69+
70+
# Verify Added Item
71+
getItemName = @driver.find_element(:xpath, '/html/body/div/div/div/ul/li[6]/span').text
72+
assert_equal(getItemName, item_name )
73+
end
74+
75+
def teardown
76+
@driver.quit
77+
end
78+
79+
end

Diff for: README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Ruby-UnitTest-Selenium
2+
3+
# Setup
4+
* clone repository from https://github.com/LambdaTest/Ruby-UnitTest-Selenium.git
5+
* install ruby in your system.
6+
* run command gem bundle
7+
* run command bundle install
8+
* Update Lambdatest user and appkey in config.conf file
9+
10+
# Execution
11+
* run command ruby LambdaTest.rb

Diff for: config.conf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
LT_USERNAME=YOUR LAMBDATEST USERNAME
2+
LT_APPKEY=YOUR LAMBDATEST ACCESSKEY
3+
LT_OPERATING_SYSTEM = win10
4+
LT_BROWSER=chrome
5+
LT_BROWSER_VERSION=63.0
6+
7+

Diff for: readConf.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require ('rubygems')
2+
require ('parseconfig')
3+
4+
class ReadConfig
5+
6+
#function to read .conf file
7+
def getDetails(key)
8+
my_config = ParseConfig.new( File.expand_path(File.dirname(__FILE__)) +'/config.conf')
9+
value = my_config.params[key]
10+
return value
11+
end
12+
end
13+

0 commit comments

Comments
 (0)