def addComment(driver, data): edit(driver, x='edit', i=1) engine(driver, data) checkText = driver.find_elements_by_class_name('card-text') assert (checkText[len(checkText) - 1].text == data[0]['value']), 'Add comment failed' xbtn = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/header/button') xbtn.click()
def basicInfo(driver, data): engine(driver, data) sleep(1) info = driver.find_elements_by_class_name('form-control') for idx, elem in enumerate(info): if idx < 4: assert (elem.get_attribute('value') == data[idx + 1]['value'] ), 'Basic info change failed' elif idx == 4: assert ( elem.get_attribute('value') == ''), 'Basic info change failed' break
def searchButton(driver, data): engine(driver, data) allText = driver.find_element_by_class_name('vs__dropdown-menu') searchText = allText.text searchText = searchText.split('\n') searchText = searchText[0].split(' ') sField = driver.find_element_by_xpath( '/html/body/div/div/div/div/main/div/div/div[1]/div/div[2]/div/div[1]/div/div[1]/input' ) sField.send_keys(searchText[0]) allText = driver.find_element_by_class_name('vs__dropdown-menu') allText.click() checkElem = driver.find_element_by_class_name('bg-primary') assert (checkElem.value_of_css_property('background-color') == 'rgba(32, 168, 216, 1)'), 'Search button failed'
def editGraphic(driver, data): edit(driver, x='edit', i=0) engine(driver, data) edit(driver, x='edit', i=0) nameCheck = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/div/div/form/div[1]/div/input') aboutCheck = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/div/div/form/div[3]/div/textarea') sleep(1) xbtn = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/footer/button[1]') xbtn.click() assert (nameCheck.get_attribute('value') == data[0]['value'] and aboutCheck.get_attribute('value') == data[1]['value']), 'Failed edit graphic'
def Deadline(driver, data): edit(driver, x='edit', i=1) engine(driver, data) edit(driver, x='edit', i=1) startDate = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/div/div/div/form[1]/div[2]/div/input' ) finishDate = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/div/div/div/form[1]/div[3]/div/input' ) assert (startDate.get_attribute('value') == data[0]['value1'] and finishDate.get_attribute('value') == data[1]['value1']), 'Deadline failed' sleep(1) xbtn = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/footer/button[1]') xbtn.click()
def drag(driver, data): engine(driver, data) driver.refresh() source = driver.find_elements_by_class_name('mb-0') target = driver.find_elements_by_class_name('drag-inner-list') for idx, elem in enumerate(source): if idx == 0: continue else: sleep(1) ActionChains(driver).drag_and_drop(source[idx], target[idx]).perform() sleep(1) # elem = driver.find_element_by_xpath('/html/body/div/div/div/div/main/div/div[3]/ul/li[1]/ul/li[1]/div') # target = driver.find_element_by_xpath('/html/body/div/div/div/div/main/div/div[3]/ul/li[2]/ul') # ActionChains(driver).drag_and_drop(elem, target).perform() sleep(1)
def createNode(driver, data): preNode = driver.find_elements_by_class_name('mindmap-node') edit(driver, x='add', i=0) engine(driver, data) selects = driver.find_elements_by_id('basicSelect') for elem in selects: if elem == selects[0]: continue else: elem.click() for option in elem.find_elements_by_tag_name('option'): for element in data: if element['path'] == None: if option.text == element['value']: option.click( ) # select() in earlier versions of webdriver break sleep(2) okBtn = driver.find_element_by_xpath( '/html/body/div[2]/div[1]/div/div/footer/button[2]') okBtn.click() sleep(2) curNode = driver.find_elements_by_class_name('mindmap-node') assert (len(preNode) < len(curNode)), 'Create node faileds'
def deleteNode(driver, data): preNode = driver.find_elements_by_class_name('mindmap-node') edit(driver, x='delete', i=1) engine(driver, data) curNode = driver.find_elements_by_class_name('mindmap-node') assert (len(preNode) > len(curNode)), 'Delete node failed'
def backHomepage(driver, data): engine(driver, data)
def createCompany(driver, data): pre = driver.find_elements_by_class_name('button') engine(driver, data) cur = driver.find_elements_by_class_name('button') assert (pre < cur), 'Create company failed'
def createAccount(driver, data): # TODO xpath iig yalgah engine(driver, data)
def changePassword(driver, data): engine(driver, data) check = driver.find_element_by_class_name('text-success') assert (check.text == 'Password has changed'), 'Password change failed'
def logOut(driver, data): engine(driver, data) url = driver.current_url assert (url == 'https://auth.bolor.net/login?t=MindTask'), 'Logout failed'
def logIn(driver, data): engine(driver, data) url = driver.current_url assert (url == 'https://mindtask.app/#/mindmap'), 'Login failed' sleep(1)
def deleteGraphic(driver, data): pre = graphicNumber(driver) engine(driver, data) cur = graphicNumber(driver)
def chooseGraphic(driver, data): engine(driver, data) # driver.find_element_by_xpath('/html/body/div/div/div/div/main/div/div/div[1]/div/div[1]/button/button').click() # el = driver.find_element_by_xpath('/html/body/div/div/div/div/main/div/div/div[1]/div/div[1]/ul/div/div/div[2]/section[1]/form/div/div/div/table/tbody/tr[2]') # el.click() sleep(1)