Skip to content

Commit

Permalink
fix remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 5, 2023
1 parent ce24b17 commit 0e8b58e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void Downloads()

((RemoteWebDriver)driver).DownloadFile(downloadableFile, targetDirectory);

string fileContent = File.ReadAllText(Path.Combine(targetDirectory, fileName));
string fileContent = File.ReadAllText(Path.Combine(targetDirectory, downloadableFile));
Assert.AreEqual("Hello, World!", fileContent.Trim());

((RemoteWebDriver)driver).DeleteDownloadableFiles();
Expand Down
4 changes: 2 additions & 2 deletions examples/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def wait_for_server(url, timeout):


@pytest.fixture(scope="function")
def server(request):
def server():
_host = "localhost"
_port = free_port()
_path = os.path.join(
Expand Down Expand Up @@ -183,7 +183,7 @@ def server(request):

process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

def wait_for_server(url, timeout=10):
def wait_for_server(url, timeout=20):
start = time.time()
while time.time() - start < timeout:
try:
Expand Down
2 changes: 1 addition & 1 deletion examples/ruby/spec/browsers/firefox_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
end

it 'uninstalls addon' do
extension_file_path = File.expand_path('../extensions/webextensions-selenium-example.xpi', __dir__)
extension_file_path = File.expand_path('../spec_support/extensions/webextensions-selenium-example.xpi', __dir__)
extension_id = driver.install_addon(extension_file_path)

driver.uninstall_addon(extension_id)
Expand Down
31 changes: 15 additions & 16 deletions examples/ruby/spec/drivers/remote_webdriver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@
background: true,
args: %w[--selenium-manager true --enable-managed-downloads true])
end
let(:driver) do
options = Selenium::WebDriver::Options.chrome
@driver = Selenium::WebDriver.for :remote, url: server.webdriver_url, options: options
end
let(:grid_url) { server.webdriver_url }

before { server.start }
after { server.stop }

it 'starts remotely' do
options = Selenium::WebDriver::Options.chrome
@driver = Selenium::WebDriver.for :remote, url: grid_url, options: options
driver = Selenium::WebDriver.for :remote, url: grid_url, options: options

expect { @driver.session_id }.not_to raise_exception
expect { driver.session_id }.not_to raise_exception
end

it 'uploads' do
options = Selenium::WebDriver::Options.chrome
driver = Selenium::WebDriver.for :remote, url: server.webdriver_url, options: options

driver.get('https://the-internet.herokuapp.com/upload')
upload_file = File.expand_path('../spec_support/selenium-snapshot.png', __dir__)

Expand All @@ -42,26 +41,26 @@

it 'downloads' do
options = Selenium::WebDriver::Options.chrome(enable_downloads: true)
@driver = Selenium::WebDriver.for :remote, url: grid_url, options: options
driver = Selenium::WebDriver.for :remote, url: grid_url, options: options

file_names = %w[file_1.txt file_2.jpg]
@driver.get('https://www.selenium.dev/selenium/web/downloads/download.html')
@driver.find_element(id: 'file-1').click
@driver.find_element(id: 'file-2').click
wait.until { @driver.downloadable_files.include? 'file_2.jpg' }
driver.get('https://www.selenium.dev/selenium/web/downloads/download.html')
driver.find_element(id: 'file-1').click
driver.find_element(id: 'file-2').click
wait.until { driver.downloadable_files.include? 'file_2.jpg' }

files = @driver.downloadable_files
files = driver.downloadable_files

expect(files).to eq file_names
downloadable_file = files.first

@driver.download_file(downloadable_file, target_directory)
driver.download_file(downloadable_file, target_directory)

file_content = File.read("#{target_directory}/#{file_name}").strip
file_content = File.read("#{target_directory}/#{downloadable_file}").strip
expect(file_content).to eq('Hello, World!')

@driver.delete_downloadable_files
driver.delete_downloadable_files

expect(@driver.downloadable_files).to be_empty
expect(driver.downloadable_files).to be_empty
end
end

0 comments on commit 0e8b58e

Please sign in to comment.