Skip to content

Instantly share code, notes, and snippets.

@xbns
Last active January 10, 2024 19:29
Show Gist options
  • Save xbns/499235d0f098dcc97451e9637e7a9080 to your computer and use it in GitHub Desktop.
Save xbns/499235d0f098dcc97451e9637e7a9080 to your computer and use it in GitHub Desktop.
#tech
"""
__author_ = "Josphat Mutuku"
__date__ ="2019-07-03"
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import unittest
class verifyMessageTest(unittest.TestCase):
def test_displayedMessage(self):
url="https://www.ultimateqa.com/filling-out-forms"
driver = webdriver.Firefox()
driver.implicitly_wait(5)
driver.get(url)
try:
contactField = driver.find_element(By.ID,"et_pb_contact_name_0")
contactField.send_keys("Josphat")
messageField = driver.find_element(By.ID, "et_pb_contact_message_0")
messageField.send_keys("Please show the sitemap for ultimateqa")
submitButton = driver.find_element(By.CLASS_NAME, "et_contact_bottom_container")
submitButton.click()
displayedMessage = driver.find_element(By.CLASS_NAME, "et-pb-contact-message")
except NoSuchElementException:
assert(displayedMessage == 'Form filled out successfully')
if __name__ == '__main__':
unittest.main()
"""
Usage:
$ python verify-message.py
Expected Output:
$ python verify-message.py
.
----------------------------------------------------------------------
Ran 1 test in 21.360s
OK
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment