Skip to content

Commit

Permalink
Rewrite all tests requested for new browser for safari
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Medvedev committed Dec 15, 2023
1 parent c82c481 commit 623cfcc
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ jobs:
run: |
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.16.0/selenium-server-4.16.1.jar -O selenium-server.jar
- name: Setup hub
run: /usr/local/opt/openjdk@11/bin/java -jar selenium-server.jar hub > selenium-hub.log 2>&1 &

- name: Setup node
run: /usr/local/opt/openjdk@11/bin/java -jar selenium-server.jar node -I "safari" > selenium-node.log 2>&1 &
- name: Setup standalone
run: /usr/local/opt/openjdk@11/bin/java -jar selenium-server.jar standalone -I 'safari' > selenium-standalone.log 2>&1 &


- name: Run tests for macos
run: |
gtimeout 60 bash -c 'while ! wget -O /dev/null -T 1 http://localhost:4444/readyz; do echo waiting for selenium server; sleep 1; done' || (cat selenium-hub.log selenium-node.log && exit 2)
gtimeout 60 bash -c 'while ! wget -O /dev/null -T 1 http://localhost:4444/readyz; do echo waiting for selenium server; sleep 1; done' || (cat selenium-standalone.log && exit 2)
tox -e tests_macos_selenium -- -m macos -n 1 tests/test_webdriver_remote.py;
97 changes: 97 additions & 0 deletions tests/test_webdriver_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,100 @@ def test_support_with_statement(self):
def test_should_be_able_to_change_user_agent(self):
"Remote should not support custom user agent"
pass

# Safari doesn't support multisessions.
# So next test must be rewrited without getting new browser
def test_can_forward_on_history(self):
next_url = f"{EXAMPLE_APP}iframe"

self.browser.visit(EXAMPLE_APP)
self.browser.visit(next_url)
self.browser.back()

self.browser.forward()
assert next_url == self.browser.url

def test_create_and_access_a_cookie(self):
"""Should be able to create and access a cookie"""
self.browser.visit(self.EXAMPLE_APP)

self.browser.cookies.add({"sha": "zam"})

assert "zam" == self.browser.cookies["sha"]

def test_create_many_cookies_at_once_as_dict(self):
"""Should be able to create many cookies at once as dict"""
self.browser.visit(self.EXAMPLE_APP)

cookies = {"sha": "zam", "foo": "bar"}
self.browser.cookies.add(cookies)

assert "zam" == self.browser.cookies["sha"]
assert "bar" == self.browser.cookies["foo"]

def test_create_some_cookies_and_delete_them_all(self):
"""Should be able to delete all cookies"""
self.browser.visit(self.EXAMPLE_APP)

self.browser.cookies.add({"whatever": "and ever"})
self.browser.cookies.add({"anothercookie": "im bored"})
self.browser.cookies.delete_all()

assert {} == self.browser.cookies

def test_create_and_delete_a_cookie(self):
"""Should be able to create and destroy a cookie"""
self.browser.visit(self.EXAMPLE_APP)

self.browser.cookies.delete_all()
self.browser.cookies.add({"cookie": "with milk"})
self.browser.cookies.delete("cookie")

assert {} == self.browser.cookies

def test_create_and_delete_many_cookies(self):
"""Should be able to create and destroy many cookies"""
self.browser.visit(self.EXAMPLE_APP)

self.browser.cookies.delete_all()
self.browser.cookies.add({"acookie": "cooked"})
self.browser.cookies.add({"anothercookie": "uncooked"})
self.browser.cookies.add({"notacookie": "halfcooked"})
self.browser.cookies.delete("acookie", "notacookie")

assert "uncooked" == self.browser.cookies["anothercookie"]

def test_try_to_destroy_an_absent_cookie_and_nothing_happens(self):
self.browser.visit(self.EXAMPLE_APP)

self.browser.cookies.delete_all()
self.browser.cookies.add({"foo": "bar"})
self.browser.cookies.delete("mwahahahaha")

{"foo": "bar"} == self.browser.cookies

def test_create_and_get_all_cookies(self):
"""Should be able to create some cookies and retrieve them all"""

self.browser.visit(self.EXAMPLE_APP)

self.browser.cookies.delete_all()
self.browser.cookies.add({"taco": "shrimp"})
self.browser.cookies.add({"lavar": "burton"})

assert 2 == len(self.browser.cookies.all())

self.browser.cookies.delete_all()

assert {} == self.browser.cookies.all()

def test_create_and_use_contains(self):
"""Should be able to create many cookies at once as dict"""

self.browser.visit(self.EXAMPLE_APP)

cookies = {"sha": "zam"}
self.browser.cookies.add(cookies)

assert "sha" in self.browser.cookies
assert "foo" not in self.browser.cookies

0 comments on commit 623cfcc

Please sign in to comment.