Skip to content

Commit

Permalink
[ci][py] Init launcher tests for Edge
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Nov 14, 2024
1 parent 6819795 commit 2bd18eb
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 4 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ jobs:
fail-fast: false
matrix:
include:
- browser: safari
os: macos
- browser: chrome
os: ubuntu
- browser: edge
Expand All @@ -113,4 +111,24 @@ jobs:
browser: ${{ matrix.browser }}
os: ${{ matrix.os }}
cache-key: py-browser-${{ matrix.browser }}
run: bazel test --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
run: |
bazel test --flaky_test_attempts 3 //py:common-${{ matrix.browser }}-bidi
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
safari-tests:
name: Browser Tests
needs: build
uses: ./.github/workflows/bazel.yml
strategy:
fail-fast: false
matrix:
include:
- browser: safari
os: macos
with:
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
browser: ${{ matrix.browser }}
os: ${{ matrix.os }}
cache-key: py-browser-${{ matrix.browser }}
run: |
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@ Run unit tests with:
bazel test //py:unit
```

To run common tests with a specific browser:

```sh
bazel test //py:common-<browsername>
```

To run common tests with a specific browser (include BiDi tests):

```sh
bazel test //py:common-<browsername>-bidi
```

To run tests with a specific browser:

```sh
Expand Down
8 changes: 7 additions & 1 deletion py/test/selenium/webdriver/common/typing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait


def test_should_fire_key_press_events(driver, pages):
Expand Down Expand Up @@ -49,6 +51,7 @@ def test_should_type_lower_case_letters(driver, pages):
pages.load("javascriptPage.html")
keyReporter = driver.find_element(by=By.ID, value="keyReporter")
keyReporter.send_keys("abc def")
WebDriverWait(driver, 2).until(EC.text_to_be_present_in_element_value((By.ID, "keyReporter"), "abc def"))
assert keyReporter.get_attribute("value") == "abc def"


Expand Down Expand Up @@ -98,6 +101,7 @@ def test_should_be_able_to_use_arrow_keys(driver, pages):
pages.load("javascriptPage.html")
keyReporter = driver.find_element(by=By.ID, value="keyReporter")
keyReporter.send_keys("Tet", Keys.ARROW_LEFT, "s")
WebDriverWait(driver, 2).until(EC.text_to_be_present_in_element_value((By.ID, "keyReporter"), "Test"))
assert keyReporter.get_attribute("value") == "Test"


Expand Down Expand Up @@ -212,6 +216,7 @@ def test_lower_case_alpha_keys(driver, pages):
element = driver.find_element(by=By.ID, value="keyReporter")
lowerAlphas = "abcdefghijklmnopqrstuvwxyz"
element.send_keys(lowerAlphas)
WebDriverWait(driver, 2).until(EC.text_to_be_present_in_element_value((By.ID, "keyReporter"), lowerAlphas))
assert element.get_attribute("value") == lowerAlphas


Expand All @@ -235,7 +240,7 @@ def test_all_printable_keys(driver, pages):
element = driver.find_element(by=By.ID, value="keyReporter")
allPrintable = "!\"#$%&'()*+,-./0123456789:<=>?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ [\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
element.send_keys(allPrintable)

WebDriverWait(driver, 2).until(EC.text_to_be_present_in_element_value((By.ID, "keyReporter"), allPrintable))
assert element.get_attribute("value") == allPrintable
assert "up: 16" in result.text.strip()

Expand Down Expand Up @@ -282,6 +287,7 @@ def test_special_space_keys(driver, pages):
pages.load("javascriptPage.html")
element = driver.find_element(by=By.ID, value="keyReporter")
element.send_keys("abcd" + Keys.SPACE + "fgh" + Keys.SPACE + "ij")
WebDriverWait(driver, 2).until(EC.text_to_be_present_in_element_value((By.ID, "keyReporter"), "abcd fgh ij"))
assert element.get_attribute("value") == "abcd fgh ij"


Expand Down
16 changes: 16 additions & 0 deletions py/test/selenium/webdriver/edge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
34 changes: 34 additions & 0 deletions py/test/selenium/webdriver/edge/edge_launcher_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import pytest


@pytest.mark.no_driver_after_test
def test_launch_and_close_browser(clean_driver, clean_service):
driver = clean_driver(service=clean_service)
driver.quit()


@pytest.mark.no_driver_after_test
def test_we_can_launch_multiple_edge_instances(clean_driver, clean_service):
driver1 = clean_driver(service=clean_service)
driver2 = clean_driver(service=clean_service)
driver3 = clean_driver(service=clean_service)
driver1.quit()
driver2.quit()
driver3.quit()

0 comments on commit 2bd18eb

Please sign in to comment.