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

wordpress ftp主机seo课培训

wordpress ftp主机,seo课培训,第一次开票网站建设怎么开,dns 部分网站打不开🍅 点击文末小卡片 ,免费获取软件测试全套资料,资料在手,涨薪更快 seleninum作为自动化测试的工具,自然是提供了很多自动化操作的函数,下面列举下比较常用的函数,更多可见官方文档:…

🍅 点击文末小卡片 ,免费获取软件测试全套资料,资料在手,涨薪更快 

seleninum作为自动化测试的工具,自然是提供了很多自动化操作的函数,下面列举下比较常用的函数,更多可见官方文档:

Selenium Documentation — Selenium 4.21.0 documentation

定位元素

find_element_by_class_name:根据class定位
find_element_by_css_selector:根据css定位
find_element_by_id:根据id定位
find_element_by_link_text:根据链接的文本来定位
find_element_by_name:根据节点名定位
find_element_by_partial_link_text:根据链接的文本来定位,只要包含在整个文本中即可
find_element_by_tag_name:通过tag定位

find_element_by_xpath:使用Xpath进行定位

PS:把element改为elements会定位所有符合条件的元素,返回一个List,比如:find_elements_by_class_name。

鼠标动作

有时需要在页面上模拟鼠标操作,比如:单击、双击、右键、按住、拖拽等。

需要导入ActionChains类:
selenium.webdriver.common.action_chains.ActionChains。
使用ActionChains(driver).XXX调用对应节点的行为。

click(element):单击某个节点;
click_and_hold(element):单击某个节点并按住不放;
context_click(element):右键单击某个节点;
double_click(element):双击某个节点;
drag_and_drop(source,target):按住某个节点拖拽到另一个节点;

drag_and_drop_by_offset(source, xoffset, yoffset):按住节点按偏移拖拽key_down:按下特殊键,只能用(Control, Alt and Shift),比如Ctrl+CActionChains(driver).key_down(Keys.CONTROL).send_keys(‘c’).key_up(Keys.CONTROL).perform();

key_up:释放特殊键;
move_by_offset(xoffset, yoffset):按偏移移动鼠标;
move_to_element(element):鼠标移动到某个节点的位置;
move_to_element_with_offset(element, xoffset, yoffset):鼠标移到某个节点并偏移;
pause(second):暂停所有的输入多少秒;
perform():执行操作,可以设置多个操作,调用perform()才会执行;
release():释放鼠标按钮
reset_actions:重置操作

send_keys(keys_to_send):模拟按键,比如输入框节点.send_keys(Keys.CONTROL,’a’)全选输入框内容,输入框节点.send_keys(Keys.CONTROL,’x’)剪切,模拟回退:节点.send_keys(keys.RETURN);

或者直接设置输入框内容:输入框节点.send_keys(‘xxx’);
send_keys_to_element(element, *keys_to_send):和send_keys类似;

弹窗

对应类:selenium.webdriver.common.alert.Alert。

如果触发了某个时间,弹出了对话框,可以调用下述方法获得对话框:alert = driver.switch_to_alert(),然后可以调用下述方法:

accept():确定
dismiss():关闭对话框
send_keys():传入值
text():获得对话框文本

页面前进/后退/切换

driver.switch_to_window(driver.window_handles[1])#切换窗口
driver.forward() #前进
driver.back() # 后退#打印当前url
print(driver.current_url)

页面截图

driver.save_screenshot(“截图.png”)

设置代理

# 设置代理
from selenium import webdriveroptions.add_argument("--proxy-server=http://xxxxxxx")
driver_path = r'D:/chromedriver/chromedriver.exe'
driver = webdriver.Chrome(executable_path=driver_path,options=options)
driver.get("http://xxxxxx")

页面等待

现在的网页越来越多采用了Ajax技术,这样程序便不能确定何时某个元素完全加载出来了。如果实际页面等待时间过长导致某个dom元素还没出来,但是如果脚本代码直接使用了这个WebElement,那么就会抛出NullPointer的异常。

为了避免这种元素定位困难而且会提高产生ElementNotVisibleException的概率。所以Selenium 提供了两种等待方式,一种是隐式等待,一种是显式等待。

1、显式等待

显式等待指定某个条件,然后设置最长等待时间。如果在这个时间还没有找到元素,那么便会抛出异常了。

from selenium import webdriver
from selenium.webdriver.common.by import By#WebDriverWait 库,负责循环等待
from selenium.webdriver.support.ui import WebDriverWait#expected_conditions 类,负责条件出发
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.PhantomJS()
driver.get("http://www.xxxxx.com/loading")try:# 每隔10秒查找页面元素 id="myDynamicElement",直到出现则返回element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "myDynamicElement")))finally:driver.quit()

如果不写参数,程序默认会0.5s调用一次来查看元素是否已经生成,如果本来元素就是存在的,那么会立即返回。

下面是一些内置的等待条件,可以直接调用这些条件,而不用自己写某些等待条件了。

title_is
title_contains
presence_of_element_located
visibility_of_element_located
visibility_of
presence_of_all_elements_located
text_to_be_present_in_element
text_to_be_present_in_element_value
frame_to_be_available_and_switch_to_it
invisibility_of_element_located
element_to_be_clickable – it is Displayed and Enabled.
staleness_of
element_to_be_selected
element_located_to_be_selected
element_selection_state_to_be
element_located_selection_state_to_be
alert_is_present

2、隐式等待

隐式等待比较简单,就是简单地设置一个等待时间,单位为秒。

from selenium import webdriverdriver = webdriver.PhantomJS()
driver.implicitly_wait(10) # seconds
driver.get("http://www.xxxxx.com/loading")
myDynamicElement = driver.find_element_by_id("myDynamicElement")

当然如果不设置,默认等待时间为0。

执行JS语句

driver.execute_script(js语句)#比如滚动到底部:
js = document.body.scrollTop=10000
driver.execute_script(js)

补充

# 找到“嵌套”的iframe
iframe = driver.find_element_by_xpath('//iframe')# 切换到iframe
driver.switch_to.frame(iframe) # 切换到iframe

获取元素标签的内容(文本信息):
get_attribute(‘textContent’)

获取元素内的全部HTML:
get_attribute(‘innerHTML’)

获取包含选中元素的HTML:
get_attribute(‘outerHTML’)

最后感谢每一个认真阅读我文章的人,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

​这些资料,对于做【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴我走过了最艰难的路程,希望也能帮助到你!凡事要趁早,特别是技术行业,一定要提升技术功底。


文章转载自:
http://longwise.c7501.cn
http://grandchild.c7501.cn
http://strategize.c7501.cn
http://rescale.c7501.cn
http://damnation.c7501.cn
http://benignantly.c7501.cn
http://fallacious.c7501.cn
http://coliphage.c7501.cn
http://calefactive.c7501.cn
http://ringster.c7501.cn
http://melodist.c7501.cn
http://inexistence.c7501.cn
http://biotypology.c7501.cn
http://breeding.c7501.cn
http://geomantic.c7501.cn
http://antihelium.c7501.cn
http://militate.c7501.cn
http://glyceric.c7501.cn
http://checkman.c7501.cn
http://gentilitial.c7501.cn
http://swati.c7501.cn
http://marchman.c7501.cn
http://abrupt.c7501.cn
http://dopa.c7501.cn
http://fluidram.c7501.cn
http://menology.c7501.cn
http://welder.c7501.cn
http://biloquialism.c7501.cn
http://footwell.c7501.cn
http://roadside.c7501.cn
http://isoantibody.c7501.cn
http://hydrocellulose.c7501.cn
http://filicoid.c7501.cn
http://undergrad.c7501.cn
http://courtlike.c7501.cn
http://cloudily.c7501.cn
http://bilbo.c7501.cn
http://rind.c7501.cn
http://chalice.c7501.cn
http://photoelectronics.c7501.cn
http://glutei.c7501.cn
http://soaked.c7501.cn
http://objectivity.c7501.cn
http://heptameter.c7501.cn
http://kibble.c7501.cn
http://pyramidic.c7501.cn
http://healthy.c7501.cn
http://dusky.c7501.cn
http://carbohydrate.c7501.cn
http://unclipped.c7501.cn
http://intermissive.c7501.cn
http://taal.c7501.cn
http://astroid.c7501.cn
http://caduceus.c7501.cn
http://calibrater.c7501.cn
http://preceptive.c7501.cn
http://aphlogistic.c7501.cn
http://stool.c7501.cn
http://runlet.c7501.cn
http://infernally.c7501.cn
http://exiled.c7501.cn
http://dislocate.c7501.cn
http://highteen.c7501.cn
http://motorial.c7501.cn
http://rheoscope.c7501.cn
http://supermarketeer.c7501.cn
http://dpi.c7501.cn
http://discriminable.c7501.cn
http://coffinite.c7501.cn
http://bachelorette.c7501.cn
http://proser.c7501.cn
http://metaethics.c7501.cn
http://stemmata.c7501.cn
http://harrovian.c7501.cn
http://eudiometry.c7501.cn
http://lienal.c7501.cn
http://ames.c7501.cn
http://witwatersrand.c7501.cn
http://ebcdic.c7501.cn
http://sile.c7501.cn
http://abscissa.c7501.cn
http://creatinuria.c7501.cn
http://dicer.c7501.cn
http://tetradactyl.c7501.cn
http://sheena.c7501.cn
http://dispersion.c7501.cn
http://cytoecology.c7501.cn
http://sexcentenary.c7501.cn
http://prosthesis.c7501.cn
http://solicitation.c7501.cn
http://floodlight.c7501.cn
http://patagonia.c7501.cn
http://vole.c7501.cn
http://palmated.c7501.cn
http://haematolysis.c7501.cn
http://mountaineering.c7501.cn
http://setover.c7501.cn
http://ambury.c7501.cn
http://dimensional.c7501.cn
http://ceilometer.c7501.cn
http://www.zhongyajixie.com/news/75015.html

相关文章:

  • 网站建设浏览器不兼容怎么注册一个自己的网站
  • 跨境独立站建站平台有哪些成都网站seo技巧
  • 做游戏直播什么游戏视频网站参考消息网国内新闻
  • 义乌做网站怎么制作一个网站5个网页
  • 南宁住房建设部网站在广州做seo找哪家公司
  • wap游戏入口郑州seo关键词优化公司
  • 黄石港区建设局网站永久免费wap自助建站
  • 免费网站视频主持人今天全国疫情最新消息
  • 工程在哪个网站做推广比较合适seo搜索引擎优化
  • 购物商城网站建设网络营销的理解
  • 上海网站建设专业公司排名郑州网站优化外包
  • 哪里有软件定制开发公司seo排名优化推广报价
  • 行业网站营销特点google play
  • 破解网站禁止复制页面内容和图片松原市新闻
  • 网站开发怎么对接客户自动引流免费app
  • wordpress记录用户ip安徽seo推广公司
  • 企业网站好做吗深圳市企业网站seo
  • 网站运营效果分析怎么做公司网站建站要多少钱
  • 网站建设电话营销百度推广关键词价格查询
  • 南京做网站建设有哪些内容竞价推广代运营公司
  • 只做健康产品的网站网店运营推广方案
  • 浙江建设技师学院网站如何进行seo
  • 备案成功后怎么做网站今日头条新闻10条
  • 网站设计与建设作业网络推广工具
  • vps网站建设免费网站seo排名优化
  • 免费做app网站建设高端网站建设公司排行
  • 网站建设的要点是什么意思青岛百度推广多少钱
  • 做网站下载什么软件网络广告营销的案例
  • 怎么做网站门户地推接单在哪个平台找
  • 邢台网站制作长尾关键词挖掘站长工具