Beispiel #1
0
    def __init__(self, driver):

        CommonPage.__init__(self, driver)
        formDriver = self.entry_form_by_id(id_="distriBtn", formId="distriModal")

        self.relateDistributeForm = toDict(
            {
                "unrelate_menu": PopMenuWithName(
                    formDriver,
                    dict(
                        driver=driver,
                        formId="unSrhMgrForm",
                        srcName="distributorName",
                        tblId="undistrModalList",
                        btnOk="related_btn",
                    ),
                    id_="unrelated",
                ),
                "relate_menu": PopMenuWithName(
                    formDriver,
                    dict(
                        driver=driver,
                        formId="srhmgrForm",
                        srcName="distributorName",
                        tblId="distrModalList",
                        btnOk="setDefault_btn",
                    ),
                    id_="related",
                ),
                "setDefault": BtnWithId(formDriver, "setDefault_btn"),
                "exit": BtnWithId(formDriver, "distriModal_closeBtn"),
            }
        )

        self.page_control = PageControl(driver)
Beispiel #2
0
	def __init__(self, driver):
		self.driver = driver

		self.page_control = PageControl(driver)

		self.enable = toDict({
			'enable_ok': BtnWithId(driver, 'openModal_okBtn')})

		self.disable = toDict({
			'disable_ok': BtnWithId(driver, 'stopModal_okBtn')})

		self.delete = toDict({
			'delete_ok': BtnWithId(driver, 'delModal_okBtn')})
Beispiel #3
0
class CommonPage(object):

	def __init__(self, driver):
		self.driver = driver

		self.page_control = PageControl(driver)

		self.enable = toDict({
			'enable_ok': BtnWithId(driver, 'openModal_okBtn')})

		self.disable = toDict({
			'disable_ok': BtnWithId(driver, 'stopModal_okBtn')})

		self.delete = toDict({
			'delete_ok': BtnWithId(driver, 'delModal_okBtn')})


	def check_isLogin(self, loginUrl):
		driver = self.driver
		count = 0
		while True:
			if driver.current_url == loginUrl:
				break
			elif count >= 10:
				print 'error'
				break
			count += 1
			time.sleep(1)


	def switch_module_by_name(self, name):
		self.page_control.switch(name)


	def wait_for_loading(self):
		self.page_control.loading()


	def entry_form_by_id(self, id_= None, formId= None):
		return self.page_control.switch_to_form(id_= id_, formId= formId)


	def entry_form_by_text(self, text= None, formId= None):
		return self.page_control.switch_to_form(text= text, formId= formId)


	def add(self, addInfo):
		addInfo = toDict(addInfo)
		for sort in self.sort:
			for key, value in self.addForm.items():
				if key == sort:
					if isinstance(value, InputWithName):
						inputValue = addInfo.get(key)
						value.type(inputValue)
					elif isinstance(value, DropMenuWithText):
						text = addInfo.get(key)
						value.choose(text)
					elif isinstance(value, DropMenuWithTitle):
						text = addInfo.get(key)
						value.choose_by_title(text)
					elif isinstance(value, PopMenuWithName):
						text = addInfo.get(key)
						value.choose(text)
					elif isinstance(value, DatePiker):
						text = addInfo.get(key)
						value.choose(text)
					# elif isinstance(value, Radio):
					# 	text = addInfo.get(key)
					# 	value.choose(text)

		self.addForm.submit.click()


	def advance_search(self, searchInfo):
		searchInfo = toDict(searchInfo)

		for key, value in self.searchForm.items():
			try:
				if isinstance(value, InputWithName):
					inputValue = searchInfo.get(key)
					value.type(inputValue)
				elif isinstance(value, DropMenuWithText):
					text = searchInfo.get(key)
					value.choose(text)
				elif isinstance(value, DropMenuWithTitle):
					text = searchInfo.get(key)
					value.choose_by_title(text)
				elif isinstance(value, PopMenuWithName):
					text = searchInfo.get(key)
					value.choose(text)
				elif isinstance(value, DatePiker):
					text = searchInfo.get(key)
					value.choose(text)
			except exceptions.NoSuchElementException as e:
				#若没找到元素,代表元素名称改变,或者元素不存在
				print '%s is not find' % key
				raise exceptions.NoSuchElementException

		self.searchForm.search.click()


	def enable_(self):
		self.page_control.switch_to_form(id_= 'openBtn')
		self.enable.enable_ok.click()

	def disable_(self):
		self.page_control.switch_to_form(id_= 'stopBtn')
		self.disable.disable_ok.click()

	def delete_(self):
		self.page_control.switch_to_form(id_= 'delBtn')
		self.delete.delete_ok.click()

	def swith_to_index(self, index):
		BtnWithId(self.driver, index).click()