-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_formySubmitBttn.py
36 lines (27 loc) · 1.22 KB
/
test_formySubmitBttn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import time
class TestButtonNavigation:
def setup_method(self):
# Set up ChromeDriver service
service = webdriver.chrome.service.Service(ChromeDriverManager().install())
# Create a WebDriver instance for Chrome
self.driver = webdriver.Chrome(service=service)
def teardown_method(self):
# Close the browser after each test
self.driver.quit()
def test_button_navigation(self):
# Open the web page with the button to be tested
self.driver.get("https://formy-project.herokuapp.com/form")
# Find the button element by its class name
button = self.driver.find_element(By.CLASS_NAME, "btn-primary")
# Click the button
button.click()
# Get the current URL after clicking the button
current_url = self.driver.current_url
# Assert that the current URL is different from the initial page
assert current_url != "https://formy-project.herokuapp.com/form"
# Wait for a moment to see the result (optional)
time.sleep(2)