-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfirefox-with-profile.rb
More file actions
54 lines (46 loc) · 1.72 KB
/
firefox-with-profile.rb
File metadata and controls
54 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'selenium-webdriver'
require 'test/unit'
class LtTest < Test::Unit::TestCase
def setup
username = ENV["LT_USERNAME"] || "{username}"
access_key = ENV["LT_ACCESS_KEY"] || "{accessToken}"
grid_url = "https://#{username}:#{access_key}@hub.lambdatest.com/wd/hub"
# Firefox profile setup
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = 'C:\\Users\\ltuser\\Downloads'
profile['browser.download.useDownloadDir'] = true
profile['browser.helperApps.neverAsk.saveToDisk'] =
"application/pdf,application/msword,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
profile['pdfjs.disabled'] = true
# Firefox Options (Selenium 4 style)
options = Selenium::WebDriver::Options.firefox
options.browser_version = "latest"
options.platform_name = "Windows 10"
options.profile = profile
# LambdaTest specific options
lt_options = {
"project" => "Ruby Firefox Profile",
"build" => "firefox-profile-test",
"name" => "Download PDF Test",
"network" => true,
"visual" => true,
"video" => true,
"console" => true,
"selenium_version" => "4.38.0"
}
options.add_option('LT:Options', lt_options)
# Start Remote WebDriver session
@driver = Selenium::WebDriver.for(:remote, url: grid_url, capabilities: options)
end
def test_Login
puts("Starting file download test...")
@driver.navigate.to("http://www.pdf995.com/samples")
# Mark test as passed for demonstration
status = "passed"
@driver.execute_script("lambda-status=#{status}")
@driver.execute_script("lambda-status=#{status}")
end
def teardown
@driver.quit
end
end