From 0e8b58ea445eb3a3deb4a7509785b624703f014e Mon Sep 17 00:00:00 2001 From: titusfortner Date: Sat, 4 Nov 2023 20:49:20 -0500 Subject: [PATCH] fix remaining --- .../Drivers/RemoteWebDriverTest.cs | 2 +- examples/python/tests/conftest.py | 4 +-- examples/ruby/spec/browsers/firefox_spec.rb | 2 +- .../spec/drivers/remote_webdriver_spec.rb | 31 +++++++++---------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/Drivers/RemoteWebDriverTest.cs b/examples/dotnet/SeleniumDocs/Drivers/RemoteWebDriverTest.cs index c1ccf03026d3..77080cdbe498 100644 --- a/examples/dotnet/SeleniumDocs/Drivers/RemoteWebDriverTest.cs +++ b/examples/dotnet/SeleniumDocs/Drivers/RemoteWebDriverTest.cs @@ -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(); diff --git a/examples/python/tests/conftest.py b/examples/python/tests/conftest.py index 30a429e5cee6..94b05f4ae67e 100644 --- a/examples/python/tests/conftest.py +++ b/examples/python/tests/conftest.py @@ -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( @@ -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: diff --git a/examples/ruby/spec/browsers/firefox_spec.rb b/examples/ruby/spec/browsers/firefox_spec.rb index c2f514a57272..b67d1dee72f4 100644 --- a/examples/ruby/spec/browsers/firefox_spec.rb +++ b/examples/ruby/spec/browsers/firefox_spec.rb @@ -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) diff --git a/examples/ruby/spec/drivers/remote_webdriver_spec.rb b/examples/ruby/spec/drivers/remote_webdriver_spec.rb index 31012249db95..e2673c89e349 100644 --- a/examples/ruby/spec/drivers/remote_webdriver_spec.rb +++ b/examples/ruby/spec/drivers/remote_webdriver_spec.rb @@ -11,10 +11,6 @@ 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 } @@ -22,12 +18,15 @@ 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__) @@ -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