From f9389a089c0e957aa5dd82039168ccbb614a7508 Mon Sep 17 00:00:00 2001 From: sandeepsuryaprasad Date: Thu, 10 Aug 2023 22:10:43 +0530 Subject: [PATCH 1/2] [py] fixed safari tests --- py/test/selenium/webdriver/common/select_class_tests.py | 6 ++++++ py/test/selenium/webdriver/safari/launcher_tests.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/py/test/selenium/webdriver/common/select_class_tests.py b/py/test/selenium/webdriver/common/select_class_tests.py index 875c962eab662..ad712b79dce5b 100644 --- a/py/test/selenium/webdriver/common/select_class_tests.py +++ b/py/test/selenium/webdriver/common/select_class_tests.py @@ -48,6 +48,7 @@ def test_select_by_index_single(driver, pages): assert sel.first_selected_option.text == select["values"][x] +@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") def test_raises_exception_select_by_index_single_disabled(driver, pages): pages.load("formPage.html") sel = Select(driver.find_element(By.NAME, disabledSingleSelect["name"])) @@ -64,6 +65,7 @@ def test_select_by_value_single(driver, pages): assert sel.first_selected_option.text == select["values"][x] +@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") def test_raises_exception_select_by_value_single_disabled(driver, pages): pages.load("formPage.html") sel = Select(driver.find_element(By.NAME, disabledSingleSelect["name"])) @@ -82,6 +84,7 @@ def test_select_by_visible_text_single(driver, pages): assert sel.first_selected_option.text == select["values"][x] +@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") def test_raises_exception_select_by_text_single_disabled(driver, pages): pages.load("formPage.html") sel = Select(driver.find_element(By.NAME, disabledSingleSelect["name"])) @@ -103,6 +106,7 @@ def test_select_by_index_multiple(driver, pages): assert selected[j].text == select["values"][j] +@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") def test_raises_exception_select_by_index_multiple_disabled(driver, pages): pages.load("formPage.html") @@ -125,6 +129,7 @@ def test_select_by_value_multiple(driver, pages): assert selected[j].text == select["values"][j] +@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") def test_raises_exception_select_by_value_multiple_disabled(driver, pages): pages.load("formPage.html") @@ -147,6 +152,7 @@ def test_select_by_visible_text_multiple(driver, pages): assert selected[j].text == select["values"][j] +@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") def test_raises_exception_select_by_text_multiple_disabled(driver, pages): pages.load("formPage.html") diff --git a/py/test/selenium/webdriver/safari/launcher_tests.py b/py/test/selenium/webdriver/safari/launcher_tests.py index 7117a9f4ba493..1d08a226d2fcd 100644 --- a/py/test/selenium/webdriver/safari/launcher_tests.py +++ b/py/test/selenium/webdriver/safari/launcher_tests.py @@ -19,6 +19,9 @@ import pytest +from selenium.common.exceptions import NoSuchDriverException +from selenium.webdriver.safari.service import Service + def test_launch(driver): assert driver.capabilities["browserName"] == "Safari" @@ -27,9 +30,9 @@ def test_launch(driver): def test_launch_with_invalid_executable_path_raises_exception(driver_class): path = "/this/path/should/never/exist" assert not os.path.exists(path) - with pytest.raises(Exception) as e: - driver_class(executable_path=path) - assert "are you running Safari 10 or later?" in str(e) + service = Service(executable_path=path) + with pytest.raises(NoSuchDriverException): + driver_class(service=service) @pytest.mark.skipif( From 5fb08d759efec9a3e19a107e945112d177de2c72 Mon Sep 17 00:00:00 2001 From: sandeepsuryaprasad Date: Fri, 11 Aug 2023 22:48:11 +0530 Subject: [PATCH 2/2] [py] modified message in xfail for safari tests --- .../selenium/webdriver/common/select_class_tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/py/test/selenium/webdriver/common/select_class_tests.py b/py/test/selenium/webdriver/common/select_class_tests.py index ad712b79dce5b..06b601555c01e 100644 --- a/py/test/selenium/webdriver/common/select_class_tests.py +++ b/py/test/selenium/webdriver/common/select_class_tests.py @@ -48,7 +48,7 @@ def test_select_by_index_single(driver, pages): assert sel.first_selected_option.text == select["values"][x] -@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") +@pytest.mark.xfail_safari(reason="options incorrectly reported as enabled") def test_raises_exception_select_by_index_single_disabled(driver, pages): pages.load("formPage.html") sel = Select(driver.find_element(By.NAME, disabledSingleSelect["name"])) @@ -65,7 +65,7 @@ def test_select_by_value_single(driver, pages): assert sel.first_selected_option.text == select["values"][x] -@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") +@pytest.mark.xfail_safari(reason="options incorrectly reported as enabled") def test_raises_exception_select_by_value_single_disabled(driver, pages): pages.load("formPage.html") sel = Select(driver.find_element(By.NAME, disabledSingleSelect["name"])) @@ -84,7 +84,7 @@ def test_select_by_visible_text_single(driver, pages): assert sel.first_selected_option.text == select["values"][x] -@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") +@pytest.mark.xfail_safari(reason="options incorrectly reported as enabled") def test_raises_exception_select_by_text_single_disabled(driver, pages): pages.load("formPage.html") sel = Select(driver.find_element(By.NAME, disabledSingleSelect["name"])) @@ -106,7 +106,7 @@ def test_select_by_index_multiple(driver, pages): assert selected[j].text == select["values"][j] -@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") +@pytest.mark.xfail_safari(reason="options incorrectly reported as enabled") def test_raises_exception_select_by_index_multiple_disabled(driver, pages): pages.load("formPage.html") @@ -129,7 +129,7 @@ def test_select_by_value_multiple(driver, pages): assert selected[j].text == select["values"][j] -@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") +@pytest.mark.xfail_safari(reason="options incorrectly reported as enabled") def test_raises_exception_select_by_value_multiple_disabled(driver, pages): pages.load("formPage.html") @@ -152,7 +152,7 @@ def test_select_by_visible_text_multiple(driver, pages): assert selected[j].text == select["values"][j] -@pytest.mark.xfail_safari(reason="Unlike chrome, safari does not raise NotImplemented error") +@pytest.mark.xfail_safari(reason="options incorrectly reported as enabled") def test_raises_exception_select_by_text_multiple_disabled(driver, pages): pages.load("formPage.html")