import Locators
import argparse
import json
import unittest
import tkinter
from tkinter.filedialog import askopenfilename
from tkinter.messagebox import askyesno
from unittest.runner import TextTestRunner
from selenium.common.exceptions import WebDriverException
from selenium.common.exceptions import InvalidSwitchToTargetException
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import InvalidElementStateException
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import StaleElementReferenceException
from selenium.common.exceptions import UnexpectedAlertPresentException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import time
from selenium.webdriver.common.by import By
from webfeatures import click
from webfeatures import design_creation
from webfeatures import login
from webfeatures import set_up
from webfeatures import field_param_setting
__author__ = 'ichistov'
class PIXlsDialogs(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""
Parse *.json configuration file and login
"""
if not hasattr(cls, "file_path"):
cls.file_path = r"D:\PIXlsDialogsConfig.json"
with open(cls.file_path) as file:
cls.json_data = json.load(file)
cls.url = cls.json_data["url"]
cls.family_pixls = cls.json_data["family"]
cls.user_login = cls.json_data["user"]["login"]
cls.user_password = cls.json_data["user"]["password"]
cls.param_change_VO = cls.json_data["param_change"]["VO"]
cls.driver = set_up()
login(driver=cls.driver, site=cls.url, user=cls.user_login, password=cls.user_password)
def test_create_pixls(self):
"""
Create pixls design and check that tabs appeared correctly
"""
design_creation(self.driver, self.family_pixls, 'pixls')
design_tabs = self.driver.find_element(By.XPATH, "//div[@id='designTabs']")
self.assertTrue(design_tabs.is_displayed(),
"Design tabs didn't appear or displayed incorrectly")
def test_input_param(self):
"""
Input value in the table row
"""
input_param = self.driver.find_element_by_id('Worksheet6')
input_param.send_keys(self.param_change_VO)
def test_choosing_checkbox(self):
"""
Open Primary and Bias window, checking installed checkbox
"""
"""
choosing_checkbox = self.driver.find_elements_by_tag_name('ul')
choosing_checkbox = self.driver.find_elements_by_tag_name('ul')
choosing_checkbox = self.driver.find_elements_by_tag_name('li')
choosing_checkbox = self.driver.find_elements_by_id('tree36')[i].click()
"""
choosing_checkbox = self.driver.find_element_by_xpath("//a[@class='tree36 hover']").click()
if __name__ == '__main__':
default_config = r"D:\PIXlsDialogsConfig.json"
parser = argparse.ArgumentParser(add_help=True,
description='Arguments for script',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--input',
default=default_config,
type=str,
help='path to configuration json file')
args = parser.parse_args()
PIXlsDialogs.file_path = args.input
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(PIXlsDialogs))
runner = TextTestRunner()
runner.run(suite)