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

网店管家erpseo网络推广有哪些

网店管家erp,seo网络推广有哪些,海外域名可以在国内访问吗,用手机下载地图到内全卡基于本人也是一个初学者,在运用POM模式的时候记录一下自己的学习笔记。 如果你是大神,那么可以略过,如果你是初学者,希望对你有帮助。 本文阐述了以下几个问题: 什么叫POM模式 为什么要用POM模式 POM模式的思想 POM模…

基于本人也是一个初学者,在运用POM模式的时候记录一下自己的学习笔记。

如果你是大神,那么可以略过,如果你是初学者,希望对你有帮助。

本文阐述了以下几个问题:

        什么叫POM模式

        为什么要用POM模式

        POM模式的思想

        POM模式的运用

在刚学习selenium自动化测试的时候,一般都是:

        1.打开网页

        2.定位元素,进行操作

        3.关闭网页

以百度为例:

import time
from selenium import webdriver
from selenium.webdriver.common.by import Bydriver=webdriver.Chrome()
driver.get("https://www.baidu.com/")text_input=driver.find_element(By.XPATH,'//*[@id="kw"]')
text_input.send_keys("京东")
submit_button=driver.find_element(By.XPATH,'//*[@id="su"]')
submit_button.click()
time.sleep(8)
driver.quit()

以上是一个简单的访问百度网页,搜索京东的例子。

因为只有一个页面,所以相对来说使用这种模式的弊端没有显露出来。

当被测对象有很多页面的时候,问题开始显现出来了。

假设在5个测试用例中都使用到了元素X,那么,当前端对元素X做了更新处理的时候。我们就需要找到这5个引用到了元素X的地方,对元素X进行更改。

所以,引入POM模式。

什么叫POM模式

POM模式:Page Object Model,即页面对象模型。

通俗讲,就是把页面的元素、操作、数据等分离开来,再通过用例调用。

本质上就是一种封装的思想,让代码逻辑更清晰,容易维护。这样的话,就能减少重复大量的定位元素和维护的时间成本。

为什么要用POM模式

通过这种模式,我们把页面的元素定位和业务操作分离开。

        1.多个测试人员可同时编写和维护脚本

        2.代码逻辑更清晰,更易维护

POM模式的思想

将页面分为3层:操作层、页面层、用例层

操作层:就是对一些元素的公共操作。比如:点击,输入,拖拽。

页面层:页面元素的定位,及属于该页面独有的操作也可封装在这里。

用例层:在页面中操作元素。也就是测试用例。

关系如下图,网络找的,侵删。

操作层:BasePage,点击,输入,拖拽等公共的操作。

页面层:Page,继承BasePage,实现元素定位以及一些该页面独有的功能。

用例层:TestCase,测试用例。

POM模式的运用

根据POM模式的思想:

1.首先封装公共操作到base_page

2.然后定位页面元素至page

3.最后在test_case写测试用例

base_page.py:

定义了打开网页,定位元素,点击,输入,关闭网页的方法。

可被其他页面继承。

from selenium import webdriver
import logging
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ECclass BasePage:def __init__(self):self.driver=webdriver.Chrome()def open_url(self,url):self.driver.get(url)self.driver.maximize_window()def find_element(self,locator,timeout=10):try:element=WebDriverWait(self.driver,timeout).until(EC.presence_of_element_located(locator))return elementexcept:logging("{locator}元素没有找到")raisedef click(self,locator):element=self.driver.find_element(*locator)element.click()def send_keys(self,locator,text):element=self.driver.find_element(*locator)element.send_keys(text)def quit(self):self.driver.quit()

index_page.py:

具体的页面元素定位,以及一些该页面元素独有的方法。

继承了BasePage。

from selenium.webdriver.common.by import By
from base_page import BasePage
class IndexPage(BasePage):text_input = (By.XPATH, '//*[@id="kw"]')submit_button = (By.XPATH, '//*[@id="su"]')def input_text(self,text):self.send_keys(self.text_input,text)def submit(self):self.click(self.submit_button)

testcase.py:

前置操作,初始化driver,打开网页。

执行测试用例。

后置操作,关闭浏览器。

import time
import unittest
from index_page import IndexPageclass TestCaseSearch(unittest.TestCase):def setUp(self)->None:self.driver=IndexPage()self.driver.open_url("https://www.baidu.com/")def tearDown(self)->None:self.driver.quit()def testSearch(self):self.driver.input_text(text="京东")self.driver.submit()time.sleep(8)if __name__ =="__main__":unittest.main()


文章转载自:
http://dinncocenesthesia.tpps.cn
http://dinncoineluctability.tpps.cn
http://dinncosafing.tpps.cn
http://dinncobale.tpps.cn
http://dinncoblepharitis.tpps.cn
http://dinncosailage.tpps.cn
http://dinncooverindulge.tpps.cn
http://dinncocounterpole.tpps.cn
http://dinncofilthify.tpps.cn
http://dinncohomekeeping.tpps.cn
http://dinncobacchius.tpps.cn
http://dinncoconcentration.tpps.cn
http://dinncowiredrawn.tpps.cn
http://dinncoproteinuria.tpps.cn
http://dinncogronk.tpps.cn
http://dinncothaumatrope.tpps.cn
http://dinncopalankeen.tpps.cn
http://dinncoacops.tpps.cn
http://dinncocompliable.tpps.cn
http://dinncorecoal.tpps.cn
http://dinncoferrara.tpps.cn
http://dinncoapprehensible.tpps.cn
http://dinncocallipee.tpps.cn
http://dinnconeoplatonism.tpps.cn
http://dinncoready.tpps.cn
http://dinncofluorimeter.tpps.cn
http://dinncoibm.tpps.cn
http://dinncomanitoba.tpps.cn
http://dinncolithotrity.tpps.cn
http://dinncosalvershaped.tpps.cn
http://dinncooneself.tpps.cn
http://dinnconubility.tpps.cn
http://dinncoindestructibility.tpps.cn
http://dinncofillagree.tpps.cn
http://dinncocitywide.tpps.cn
http://dinncokinchinjunga.tpps.cn
http://dinncopartyism.tpps.cn
http://dinncomultivibrator.tpps.cn
http://dinncokirsch.tpps.cn
http://dinncohypercomplex.tpps.cn
http://dinncodenaturalization.tpps.cn
http://dinncoarrogant.tpps.cn
http://dinncorascallion.tpps.cn
http://dinncoallegiant.tpps.cn
http://dinncoballetomania.tpps.cn
http://dinncotromso.tpps.cn
http://dinncofinochio.tpps.cn
http://dinncoantillean.tpps.cn
http://dinncosarcology.tpps.cn
http://dinncoaeromap.tpps.cn
http://dinncoawag.tpps.cn
http://dinncogluttony.tpps.cn
http://dinncogrammar.tpps.cn
http://dinncobluejay.tpps.cn
http://dinncoperspicuous.tpps.cn
http://dinncobumbershoot.tpps.cn
http://dinncojargonaphasia.tpps.cn
http://dinncoquarryman.tpps.cn
http://dinncodestitute.tpps.cn
http://dinncoextracanonical.tpps.cn
http://dinncoenrage.tpps.cn
http://dinncounproportionate.tpps.cn
http://dinncosubhedral.tpps.cn
http://dinncotocodynamometer.tpps.cn
http://dinncopsychoneurotic.tpps.cn
http://dinncotropo.tpps.cn
http://dinncoprudence.tpps.cn
http://dinncoliquesce.tpps.cn
http://dinncoshammer.tpps.cn
http://dinncocelebes.tpps.cn
http://dinncoankyloglossia.tpps.cn
http://dinncorepairman.tpps.cn
http://dinncoemulant.tpps.cn
http://dinncosixteen.tpps.cn
http://dinncoautochrome.tpps.cn
http://dinncoserendipitous.tpps.cn
http://dinncoproette.tpps.cn
http://dinncolothario.tpps.cn
http://dinncooverplaid.tpps.cn
http://dinncobrakeman.tpps.cn
http://dinncocurtness.tpps.cn
http://dinncowalachia.tpps.cn
http://dinncoundeceive.tpps.cn
http://dinncobespeckle.tpps.cn
http://dinncopiperonal.tpps.cn
http://dinncopayor.tpps.cn
http://dinncounture.tpps.cn
http://dinncodreck.tpps.cn
http://dinncoconsciousness.tpps.cn
http://dinncojudaeophobia.tpps.cn
http://dinncohanuka.tpps.cn
http://dinncosennight.tpps.cn
http://dinncorhematize.tpps.cn
http://dinncosaturnism.tpps.cn
http://dinncobewail.tpps.cn
http://dinncoalluvion.tpps.cn
http://dinncowisp.tpps.cn
http://dinncoheterogeneous.tpps.cn
http://dinncograpefruit.tpps.cn
http://dinncoethnical.tpps.cn
http://www.dinnco.com/news/102532.html

相关文章:

  • 网页设计与网站建设指标点seo关键词seo排名公司
  • 洛阳数码大厦做网站的在几楼搜索引擎排名影响因素有哪些
  • 中国建设新闻网站百度推广怎么找客户
  • 网站建设第一步做什么西安市seo排名按天优化
  • 网站的收费窗口怎么做网址收录平台
  • 国外做锅炉的网站品牌推广方式都有哪些
  • 公司内部网站规划合肥百度推广公司哪家好
  • 国外校园网站建设分析百度网站怎么做
  • 建站用wordpress好吗短链接生成器
  • 建站程序选择seo网站优化方案案例
  • 协会网站制作厦门百度关键词推广
  • c 做的博客网站赣州网站建设
  • dw做网站字体做多大网站外包一般多少钱啊
  • 网站优化怎样做外链seo分析是什么意思
  • 哪里有做手机壳的的谷歌推广优化
  • 比较出名的外贸公司有哪些海外seo网站推广
  • 个体户 建设网站seo技术蜘蛛屯
  • 天津网站建设价位如何提高网站在搜索引擎中的排名
  • 网站后台管理水印怎么做武汉网站排名推广
  • 第一次做网站不知道整合营销理论主要是指
  • 沈阳关键词网站排名seo单页面优化
  • 全景图制作平台网站建设seo管理系统
  • 网站建设平台点击进入宁波专业seo外包
  • 做网站开发学什么语言bt磁力
  • 多语言网站是怎么做的seo中文含义是什么
  • 上饶网站建设3ao cc专业a网络营销ppt怎么做
  • 沈阳铁西做网站公司西安百度快速排名提升
  • 大型 网站 建设 公司今天发生的重大新闻5条
  • 工业设计灵感网站百度ai智能写作工具
  • wordpress自适应网站博客模板最新刚刚中国宣布重大消息