Skip to content

[py] add more Internet Explorer example code #2097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 74 additions & 6 deletions examples/python/tests/browsers/test_internet_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,82 @@ def test_basic_options_win11():

driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
options = webdriver.IeOptions()
options.file_upload_timeout = 2000

driver = webdriver.Ie(options=options)

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
options = webdriver.IeOptions()
options.ensure_clean_session = True

driver = webdriver.Ie(options=options)

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
options = webdriver.IeOptions()
options.ignore_zoom_level = True

driver = webdriver.Ie(options=options)

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
options = webdriver.IeOptions()
options.ignore_protected_mode_settings = True

driver = webdriver.Ie(options=options)

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
service = webdriver.IeService(service_args=["--silent"])
driver = webdriver.Ie(service=service)

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
options = webdriver.IeOptions()
options.add_argument("-private")

driver = webdriver.Ie(options=options)

driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'
@pytest.mark.skip
def test_force_create_process_api():
options = webdriver.IeOptions()
options.force_create_process_api = True

driver = webdriver.Ie(options=options)

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
service = webdriver.IeService(log_output=log_path, log_level='INFO')
service = webdriver.IeService(log_output=log_path, log_level="INFO")

driver = webdriver.Ie(service=service)

with open(log_path, 'r') as fp:
with open(log_path, "r") as fp:
assert "Starting WebDriver server" in fp.readline()

driver.quit()
Expand All @@ -50,19 +118,19 @@ def test_log_to_stdout(capfd):

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
service = webdriver.IeService(log_output=log_path, log_level='WARN')
service = webdriver.IeService(log_output=log_path, log_level="WARN")

driver = webdriver.Ie(service=service)

with open(log_path, 'r') as fp:
assert 'Started InternetExplorerDriver server (32-bit)' in fp.readline()
with open(log_path, "r") as fp:
assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
service = webdriver.IeService(service_args=["–extract-path="+temp_dir])
service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

driver = webdriver.Ie(service=service)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,8 @@ InternetExplorerOptions options = new InternetExplorerOptions();
options.waitForUploadDialogUpTo(Duration.ofSeconds(2));
WebDriver driver = new RemoteWebDriver(options);
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.file_upload_dialog_timeout = 2000
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L28-L29" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
var options = new InternetExplorerOptions();
Expand Down Expand Up @@ -150,16 +142,8 @@ InternetExplorerOptions options = new InternetExplorerOptions();
options.destructivelyEnsureCleanSession();
WebDriver driver = new RemoteWebDriver(options);
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.ensure_clean_session = True
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L38-L39" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
var options = new InternetExplorerOptions();
Expand Down Expand Up @@ -198,16 +182,8 @@ InternetExplorerOptions options = new InternetExplorerOptions();
options.ignoreZoomSettings();
WebDriver driver = new RemoteWebDriver(options);
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.ignore_zoom_level = True
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L48-L49" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
var options = new InternetExplorerOptions();
Expand Down Expand Up @@ -256,16 +232,8 @@ InternetExplorerOptions options = new InternetExplorerOptions();
options.introduceFlakinessByIgnoringSecurityDomains();
WebDriver driver = new RemoteWebDriver(options);
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.ignore_protected_mode_settings = True
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L58-L59" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
var options = new InternetExplorerOptions();
Expand Down Expand Up @@ -303,16 +271,8 @@ InternetExplorerOptions options = new InternetExplorerOptions();
options.setCapability("silent", true);
WebDriver driver = new InternetExplorerDriver(options);
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.set_capability("silent", True)
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L68-L71" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
InternetExplorerOptions options = new InternetExplorerOptions();
Expand Down Expand Up @@ -400,17 +360,8 @@ public class ieTest {
}
}
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.add_argument('-private')
options.force_create_process_api = True
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L78-L81" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using System;
Expand Down Expand Up @@ -495,16 +446,8 @@ public class ieTest {
}
}
{{< /tab >}}
{{< tab header="Python" >}}
from selenium import webdriver

options = webdriver.IeOptions()
options.force_create_process_api = True
driver = webdriver.Ie(options=options)

driver.get("http://www.google.com")

driver.quit()
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_internet_explorer.py#L88-L91" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using System;
Expand Down Expand Up @@ -575,8 +518,8 @@ To change the logging output to save to a specific file:
Property key: `InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY`\
Property value: String representing path to log file
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L29" >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L98" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-implementation >}}
Expand Down Expand Up @@ -605,9 +548,9 @@ To change the logging output to display in the console as STDOUT:
Property key: `InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY`\
Property value: `DriverService.LOG_STDOUT` or `DriverService.LOG_STDERR`
{{% /tab %}}
{{< tab header="Python" >}}
{{< tab header="Python" text=true >}}
{{< badge-version version="4.11" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L41" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L110" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-implementation >}}
Expand Down Expand Up @@ -635,8 +578,8 @@ If logging output is specified, the default level is `FATAL`
Property key: `InternetExplorerDriverService.IE_DRIVER_LOGLEVEL_PROPERTY`\
Property value: String representation of `InternetExplorerDriverLogLevel.DEBUG.toString()` enum
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L53" >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L122" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Browsers/InternetExplorerTest.cs#L85" >}}
Expand All @@ -662,9 +605,9 @@ Property value: String representation of `InternetExplorerDriverLogLevel.DEBUG.t
Property key: `InternetExplorerDriverService.IE_DRIVER_EXTRACT_PATH_PROPERTY`\
Property value: String representing path to supporting files directory
{{< /tab >}}
{{< tab header="Python" >}}
{{< tab header="Python" text=true >}}
{{< badge-version version="4.11" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L65" >}}
{{< gh-codeblock path="examples/python/tests/browsers/test_internet_explorer.py#L134" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Browsers/InternetExplorerTest.cs#L98" >}}
Expand Down
Loading
Loading