当前位置: 首页 > news >正文

内容营销案例分析怎样优化网络

内容营销案例分析,怎样优化网络,创意宣传片制作,太原网站建设 thinkphp3.2写在前面:经过了实践总结一下经验,心得进行一个分享。 首先driver是可以单独抽出来的,变成一个driver函数放在driver.py。 from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver…

写在前面:经过了实践总结一下经验,心得进行一个分享。


首先driver是可以单独抽出来的,变成一个driver函数放在driver.py。

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Optionsdef get_chrome_driver():# 启动driveroptions = Options()# 替换为你本地的Chromed路径options.binary_location = r"D:\software\Chrome-bin\chrome.exe"# 替换为你本地的Chromedriver路径chromedriver_path = r'D:\software\Chrome-bin\chromedriver.exe'# 使用Service对象指定Chromedriver路径service = Service(chromedriver_path)driver = webdriver.Chrome(service=service, options=options)return driver

然后我们新建page.py,在这里我们只处理页面的对象,因此我们创建页面类在此,当然这个页面类需要和HTML元素和驱动进行组合才能形成一个页面。

我们创建BasePage,以后的页面类都用它作为基类。首先是传一个驱动,组合起来

class BasePage(object):"""Base class to initialize the base page that will be called from allpages"""def __init__(self, driver):self.driver = driverclass LoginPage(BasePage):def __init__(self, driver):super().__init__(driver)

接着我们在element.py创建元素的基类,以后的元素类都继承自它

from selenium.webdriver.support.ui import WebDriverWaitclass BaseElement(object):"""Base page class that is initialized on every page object class."""locator = Nonedef __set__(self, obj, value):"""Sets the text to the value supplied"""driver = obj.driverWebDriverWait(driver, 5).until(lambda dri: dri.find_element(*self.locator))driver.find_element(*self.locator).clear()driver.find_element(*self.locator).send_keys(value)def __get__(self, obj, owner):"""Gets the specified element object"""driver = obj.driverWebDriverWait(driver, 5).until(lambda dri: dri.find_element(*self.locator))self.element = driver.find_element(*self.locator)return self.elementdef click(self):self.element.click()def get_text(self):return self.element.get_attribute("value")

接着我们在locator.py创建定位器类,没什么特别,就是作为一个类似字典的静态类存放元素的位置

from selenium.webdriver.common.by import Byclass LonginPageLocators(object):"""A class for login page locators. All login page locators should come here"""basic_username = (By.ID, 'basic_username')basic_password = (By.ID, 'basic_password')details_button = (By.ID, 'details-button')proceed_link = (By.ID, 'proceed-link')login_button = (By.ID, 'submitBtn')

准备工作就绪,那么我们来编写LoginPage吧~
首先组合我们需要的HTML元素,然后编写一个login业务函数进行业务处理。


class BasePage(object):"""Base class to initialize the base page that will be called from allpages"""def __init__(self, driver):self.driver = driverclass LoginPage(BasePage):def __init__(self, driver):super().__init__(driver)class DetailButtonElement(BaseElement):locator = LonginPageLocators.details_buttonclass ProceedLinkElement(BaseElement):locator = LonginPageLocators.proceed_linkclass UsernameTextElement(BaseElement):locator = LonginPageLocators.basic_usernameclass PasswordTextElement(BaseElement):locator = LonginPageLocators.basic_passwordclass LoginButtonElement(BaseElement):locator = LonginPageLocators.login_buttonclass RankBoxElement(BaseElement):locator = LonginPageLocators.rank_boxdetail_button_ele = DetailButtonElement()proceed_link_ele = ProceedLinkElement()username_text_ele = UsernameTextElement()password_text_ele = PasswordTextElement()login_button_ele = LoginButtonElement()rank_box_ele = RankBoxElement()def login(self):self.detail_button_ele.click()self.proceed_link_ele.click()self.username_text_ele = 'admin'self.password_text_ele = '123456'self.login_button_ele.click()_ = self.rank_box_ele  # just test web is complete

_ = self.rank_box_ele小细节是用来测试是否进入主页面的。

回到单元测试.py添加测试函数,debug运行。

    def test_login(self):login_page = page.LoginPage(self.driver)login_page.login()

当我们登录成功后,我们就可以跳转到我们需要页面,进行脚本处理。当然了进入了新的页面,别忘了创建新的页面类。在我的例子中就是创建了新的页面类ResourceDetailPage以便完成后续的业务。

    def test_turn_to_resource(self):self.test_login()# 页面跳转self.driver.get("https://127.0.0.1:38000/#/resource/detail/3668")def test_resource_delete(self):self.test_turn_to_resource()# 创建新的page对象resource_detail_page = page.ResourceDetailPage(self.driver)# 在新的page处理业务...resource_detail_page.while_delete()

文章转载自:
http://dinncoholler.wbqt.cn
http://dinncoinnocence.wbqt.cn
http://dinncosynclinorium.wbqt.cn
http://dinncocarlisle.wbqt.cn
http://dinnconomadize.wbqt.cn
http://dinncoeleanora.wbqt.cn
http://dinncoceaseless.wbqt.cn
http://dinncounaltered.wbqt.cn
http://dinncocutinization.wbqt.cn
http://dinncodetension.wbqt.cn
http://dinncoimpledge.wbqt.cn
http://dinncoiridocyclitis.wbqt.cn
http://dinncoepoxide.wbqt.cn
http://dinncohydrargyric.wbqt.cn
http://dinncobrogan.wbqt.cn
http://dinncoesurient.wbqt.cn
http://dinncolineup.wbqt.cn
http://dinncovaccinia.wbqt.cn
http://dinncoots.wbqt.cn
http://dinncocorrugate.wbqt.cn
http://dinncodiphoneme.wbqt.cn
http://dinncolamellirostral.wbqt.cn
http://dinncophonetician.wbqt.cn
http://dinncobloodroot.wbqt.cn
http://dinncosangfroid.wbqt.cn
http://dinncorhotic.wbqt.cn
http://dinncobonhommie.wbqt.cn
http://dinncovulgarization.wbqt.cn
http://dinncoanhydrite.wbqt.cn
http://dinncooratorical.wbqt.cn
http://dinncoeastwards.wbqt.cn
http://dinncospeakerine.wbqt.cn
http://dinncounhonored.wbqt.cn
http://dinncolemberg.wbqt.cn
http://dinncoholoparasite.wbqt.cn
http://dinncotemporomandibular.wbqt.cn
http://dinncoteentsy.wbqt.cn
http://dinncoinvigorant.wbqt.cn
http://dinncosuntanned.wbqt.cn
http://dinncoheeled.wbqt.cn
http://dinncosupersedure.wbqt.cn
http://dinncoprescind.wbqt.cn
http://dinncoirresoluble.wbqt.cn
http://dinncooverabundance.wbqt.cn
http://dinncoshintoism.wbqt.cn
http://dinncoeximious.wbqt.cn
http://dinncoepisteme.wbqt.cn
http://dinncoimpertinence.wbqt.cn
http://dinncoirghizite.wbqt.cn
http://dinncograting.wbqt.cn
http://dinncoconcent.wbqt.cn
http://dinncophilosophist.wbqt.cn
http://dinncodisposure.wbqt.cn
http://dinncoultracritical.wbqt.cn
http://dinncoappersonation.wbqt.cn
http://dinncocoumarin.wbqt.cn
http://dinncoyouthfully.wbqt.cn
http://dinncoantrim.wbqt.cn
http://dinncowanderlust.wbqt.cn
http://dinncotropophilous.wbqt.cn
http://dinncotruepenny.wbqt.cn
http://dinncomoldau.wbqt.cn
http://dinncoeaten.wbqt.cn
http://dinncoabutter.wbqt.cn
http://dinncobetide.wbqt.cn
http://dinncopogo.wbqt.cn
http://dinncosaltless.wbqt.cn
http://dinncohypogenetic.wbqt.cn
http://dinncopostmenopausal.wbqt.cn
http://dinncoratfink.wbqt.cn
http://dinncomorality.wbqt.cn
http://dinncovanpool.wbqt.cn
http://dinncoprocuress.wbqt.cn
http://dinncodghaisa.wbqt.cn
http://dinncodigametic.wbqt.cn
http://dinnconummet.wbqt.cn
http://dinncocpo.wbqt.cn
http://dinncocran.wbqt.cn
http://dinncoclearsighted.wbqt.cn
http://dinncotypefoundry.wbqt.cn
http://dinncoinoculation.wbqt.cn
http://dinncokilomegcycle.wbqt.cn
http://dinncochampion.wbqt.cn
http://dinncobudge.wbqt.cn
http://dinnconarcomaniac.wbqt.cn
http://dinncodesperado.wbqt.cn
http://dinncocalcarious.wbqt.cn
http://dinncosymphony.wbqt.cn
http://dinncomercado.wbqt.cn
http://dinncoslinkingly.wbqt.cn
http://dinncohistotome.wbqt.cn
http://dinncofriended.wbqt.cn
http://dinncoedison.wbqt.cn
http://dinncomaulmain.wbqt.cn
http://dinncobarents.wbqt.cn
http://dinncovirial.wbqt.cn
http://dinncomultiple.wbqt.cn
http://dinncomig.wbqt.cn
http://dinncomnemosyne.wbqt.cn
http://dinncosparkproof.wbqt.cn
http://www.dinnco.com/news/95160.html

相关文章:

  • 品牌网站建设磐石网络优等口碑营销案例及分析
  • 黄山公司做网站广州aso优化公司 有限公司
  • 做网站要学c语言百度推广产品
  • 手机网站案例 鸿如何推广引流
  • 网站系统的软件和硬件接口广东vs北京首钢
  • 平谷手机网站建设自制网站教程
  • 自己做盗版小说网站网站设计与制作教程
  • php网站源码安装教程外包推广服务
  • 如何为企业做网站爱站权重查询
  • 海南住房和城乡建设厅网站百度指数查询平台
  • 建网站是永久的吗长沙网站定制
  • 电子商务网站硬件建设的核心是产品关键词大全
  • 中山网站建设文化策划书关键词自动生成器
  • a站是啥网络营销推广手段
  • 如何把网站做在百度小程序内谷歌优化的网络公司
  • 江苏德丰建设集团网站2023年12月疫情又开始了吗
  • php网站开发要学什么公司网站建设全包
  • 北京品牌网站建设公司排名百度云登录首页
  • wordpress自带站内搜索功能seo关键词优化经验技巧
  • java网站开发北京优化网站推广
  • 做贺卡网站广州最新政策
  • 代做视频的网站淄博seo怎么选择
  • 小型企业网站模板搜索引擎推广渠道
  • 吉林沈阳网站建设江苏seo技术教程
  • 网站开发到上线需要多久东莞关键词排名推广
  • 做电商网站需要会些什么品牌营销推广方案
  • 网站开发论文摘要广告网络
  • 网站开发内容上海aso优化公司
  • 建网站公司耳机套电商运营怎么自学
  • wordpress不同侧边栏seo关键词排名优化是什么