You get a bonus - 1 coin for daily activity. Now you have 1 coin

Testing in Python with Selenium and ChromeDriver

Practice



# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import NoSuchElementException
import sys
import requests

def check_exists_by_xpath():
try:
#driver.find_element(By.CSS_SELECTOR, ".error")
driver.find_element(By.ID, "#general_error")
except NoSuchElementException:
return False
return True
print("start !")
print("login:",sys.argv[1])
print("<br>")
print("pass:",sys.argv[2])
#TODO use
#options = selenium.webdriver.ChromeOptions()
#options.add_argument('headless')
#driver = webdriver.Chrome(chrome_options=options)
driver = webdriver.PhantomJS()
#driver = webdriver.Chrome(ChromeDriverManager().install())
vars = {}
driver.get("https://www.bluehost.com/web-hosting/signup")
#driver.save_screenshot("screenshot.png")
driver.set_window_size(1094, 574)
driver.find_element(By.ID, "shared-pro").click()

#driver.save_screenshot("screenshot2.png")
driver.find_element(By.ID, "domain").click()
driver.find_element(By.ID, "domain").send_keys(sys.argv[1])
#driver.save_screenshot("screenshot3.png")
error = check_exists_by_xpath()
print(error)
if error:
print(">>>if true")
driver.quit()
else:
print(">>>if false")
driver.find_element(By.CSS_SELECTOR, ".fright:nth-child(13) > .notransform").click()
driver.find_element(By.CSS_SELECTOR, ".even:nth-child(11)").click()
# driver.save_screenshot("screenshot4.png")
driver.quit()

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Quality Assurance"

Terms: Quality Assurance