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

做破解网站合法百度数据研究中心官网

做破解网站合法,百度数据研究中心官网,web框架,网站源码区别一、Alert/Confirm/Prompt弹出窗口特征说明 Alert弹出窗口: 提示用户信息只有确认按钮,无法通过页面元素定位,不关闭窗口无法在页面上做其他操作。 Confirm 弹出窗口: 有确认和取消按钮,该弹出窗口无法用页面元素定…

一、Alert/Confirm/Prompt弹出窗口特征说明

Alert弹出窗口:

提示用户信息只有确认按钮,无法通过页面元素定位,不关闭窗口无法在页面上做其他操作。

Confirm 弹出窗口:

有确认和取消按钮,该弹出窗口无法用页面元素定位,不关闭窗口无法在页面上做其他操作。

Prompt弹出窗口:

有输入框、确认和取消按钮,该弹出窗口无法用页面元素定位,不关闭窗口无法在页面上做其他操作。

注意:3种窗口为浏览器自带的窗口,该窗口无法定位到元素,能定位到元素需要使用WebElement操作。

二、Alert/Confirm/Prompt弹出窗口操作

第一步:需要获取弹出窗口,两种方法 与Alert(driver)

alert=driver.switch_to.alert

  1. from selenium.webdriver.common.alert import Alert

  2. alert=Alert(driver)

第二步:对获取到的窗口进行操作,常用方法如下:


alert.text() # 获取窗口信息alert.accept() # 确认alert.dismiss() # 取消alert.send_keys(keysToSend) # 输入信息

alert.authenticate(username, password) # 用户认证信息登录,已有确认操作

三、实例说明

创建下面3个html文件

alertTest.html


<html><head><title>Alert Test</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"/></head><script type="text/javascript">function showAlert(){alert(document.from1.t1.value);}function showMultilineAlert(){alert("你必须纠正以下错误:\n你必须输入XXXX.\n你必须做XXXX.\n你必须XXXX");}</script><body><h2>Alert Test</h2><form name="from1"><input type="text" name="t1" value="可以输入 Alert 信息"><br><br><input type="button" name="button1" value="点击Alert获取输入框信息" onclick="showAlert()"><br><br><input type="button" name="button2" value="Alert自带多行文本信息" onclick="showMultilineAlert()"><br></form></body></html>

confirmTest.html


<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"/><title>Confirm Test</title></head><script type="text/javascript">function showConfirm(){var t1 = document.from1.t1;if (confirm("请点击确认或取消")){t1.value = "确认";}else{t1.value = "取消";}}</script><body><h2>Confirm Test</h2><form name="from1"><input type="button" name="button1" value="点击Confirm按钮" onclick="showConfirm()"><br><br><input type="text" name="t1"></form></body></html>

promptTest.html


<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"/><title>Prompt Test</title></head><script type="text/javascript">function showPrompt(){var t1 = document.from1.t1;t1.value = prompt("请输入信息,信息将填入页面输入框.");}</script><body><h2>Prompt Test</h2><form name="from1"><input type="button" name="button1" value="点击Prompt按钮" onclick="showPrompt()"><br><br><input type="text" name="t1"></form></body></html>

示例1:Alert弹窗获取文本与确认操作


from selenium import webdriverfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.support.expected_conditions import alert_is_presentfrom selenium.webdriver.common.alert import Alertdriver = webdriver.Chrome()driver.get(r'E:\XXX\alertTest.html')driver.find_element_by_name('button1').click() # 点击第一个按钮WebDriverWait(driver, 5).until(alert_is_present()) # 等待弹出窗口出现alert = driver.switch_to.alert # 获取弹出窗口text1 = alert.text # 获取窗口文本信息print(text1) # 打印窗口文本信息alert.accept() # 确认print('----------')driver.find_element_by_name('button2').click() # 点击第二个按钮WebDriverWait(driver, 5).until(alert_is_present()) # 等待弹出窗口出现alert = Alert(driver) # 获取弹出窗口text1 = alert.text # 获取窗口文本信息print(text1) # 打印窗口文本信息alert.accept() # 确认driver.quit()

注意:WebDriverWait(driver, 5).until(alert_is_present()) 加上这个可提高代码的可靠性

示例2:Comfirm弹窗获取文本、确认、取消操作


driver = webdriver.Chrome()driver.get(r'E:\XXX\confirmTest.html')driver.find_element_by_name('button1').click() # 点击按钮WebDriverWait(driver, 5).until(alert_is_present()) # 等待弹出窗口出现alert = driver.switch_to.alert # 获取弹出窗口print(alert.text) # 打印窗口信息alert.accept() # 确认time.sleep(2)driver.find_element_by_name('button1').click() # 点击按钮WebDriverWait(driver, 5).until(alert_is_present()) # 等待弹出窗口出现alert = driver.switch_to.alert # 获取弹出窗口alert.dismiss() # 取消time.sleep(2)driver.quit()

示例3:Prompt 弹窗获取文本、输入内容、确认操作


driver = webdriver.Chrome()driver.get(r'E:\XXX\promptTest.html')driver.find_element_by_name('button1').click() # 点击按钮WebDriverWait(driver, 5).until(alert_is_present()) # 等待弹出窗口出现alert = Alert(driver) # Alert 获取弹出窗口alert.send_keys('selenium Alert弹出窗口输入信息') # 输入信息alert.accept() # 确认time.sleep(2)driver.quit()

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

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你!


文章转载自:
http://dinncotribonucleation.zfyr.cn
http://dinncoretinued.zfyr.cn
http://dinncosubvitreous.zfyr.cn
http://dinncoignobly.zfyr.cn
http://dinncotubbish.zfyr.cn
http://dinncoimproperly.zfyr.cn
http://dinncoindexless.zfyr.cn
http://dinncocalfbound.zfyr.cn
http://dinncospoke.zfyr.cn
http://dinnconeuralgiform.zfyr.cn
http://dinncojacksnipe.zfyr.cn
http://dinncofranchisee.zfyr.cn
http://dinncovera.zfyr.cn
http://dinncocrapshoot.zfyr.cn
http://dinncooligochrome.zfyr.cn
http://dinncoendogamy.zfyr.cn
http://dinncostrongbox.zfyr.cn
http://dinncohypophysial.zfyr.cn
http://dinncosensationalism.zfyr.cn
http://dinncomolest.zfyr.cn
http://dinncogrubstreet.zfyr.cn
http://dinncomonarchy.zfyr.cn
http://dinncocopesetic.zfyr.cn
http://dinncopansy.zfyr.cn
http://dinncobackside.zfyr.cn
http://dinncoslugging.zfyr.cn
http://dinncoturban.zfyr.cn
http://dinncopiaffe.zfyr.cn
http://dinncoenseal.zfyr.cn
http://dinncoadios.zfyr.cn
http://dinncohyaloid.zfyr.cn
http://dinncoaccomplishable.zfyr.cn
http://dinncocrenelate.zfyr.cn
http://dinncomanhandle.zfyr.cn
http://dinncocamp.zfyr.cn
http://dinncoconey.zfyr.cn
http://dinncounionides.zfyr.cn
http://dinncorestis.zfyr.cn
http://dinncoteaspoonful.zfyr.cn
http://dinncothyroxin.zfyr.cn
http://dinncoemanate.zfyr.cn
http://dinncoethosuximide.zfyr.cn
http://dinncofibroplasia.zfyr.cn
http://dinncounchangeably.zfyr.cn
http://dinncouniversity.zfyr.cn
http://dinncorho.zfyr.cn
http://dinncomesmerist.zfyr.cn
http://dinnconetscape.zfyr.cn
http://dinncoaspartase.zfyr.cn
http://dinncoratbaggery.zfyr.cn
http://dinncosylvatic.zfyr.cn
http://dinncocentinewton.zfyr.cn
http://dinncoaccrescent.zfyr.cn
http://dinncoamid.zfyr.cn
http://dinncovitreum.zfyr.cn
http://dinnconary.zfyr.cn
http://dinncosadden.zfyr.cn
http://dinncoperennially.zfyr.cn
http://dinncorioter.zfyr.cn
http://dinncoinfrasonic.zfyr.cn
http://dinncophotochromy.zfyr.cn
http://dinncotoolmaking.zfyr.cn
http://dinncofirsthand.zfyr.cn
http://dinncorainbow.zfyr.cn
http://dinncowordage.zfyr.cn
http://dinncofriday.zfyr.cn
http://dinncopowerpoint.zfyr.cn
http://dinncopott.zfyr.cn
http://dinncosectarial.zfyr.cn
http://dinncohydrogasifier.zfyr.cn
http://dinncoendlessly.zfyr.cn
http://dinncocobia.zfyr.cn
http://dinncographotherapy.zfyr.cn
http://dinncogenesis.zfyr.cn
http://dinncowhereto.zfyr.cn
http://dinncomolecule.zfyr.cn
http://dinncofourgon.zfyr.cn
http://dinncounharmful.zfyr.cn
http://dinncotonstein.zfyr.cn
http://dinncophilological.zfyr.cn
http://dinncosned.zfyr.cn
http://dinncogalactogogue.zfyr.cn
http://dinncotristich.zfyr.cn
http://dinncoconjugant.zfyr.cn
http://dinncorussellite.zfyr.cn
http://dinncopropound.zfyr.cn
http://dinncochockablock.zfyr.cn
http://dinncononcancelability.zfyr.cn
http://dinncodemonological.zfyr.cn
http://dinncosearch.zfyr.cn
http://dinncoprebasic.zfyr.cn
http://dinncofilmstrip.zfyr.cn
http://dinncosulfatase.zfyr.cn
http://dinncoremiss.zfyr.cn
http://dinncogarrotte.zfyr.cn
http://dinncomutagenesis.zfyr.cn
http://dinncopediculate.zfyr.cn
http://dinncovigorousness.zfyr.cn
http://dinncodescension.zfyr.cn
http://dinncorubbings.zfyr.cn
http://www.dinnco.com/news/129464.html

相关文章:

  • 大连做网站需要多少钱在线域名ip查询
  • 网站设计的图片互动营销案例分析
  • 免费微信微网站模板下载网络营销现状分析
  • 专业网络分销平台重庆seo优化推广
  • 宁阳网站建设搜索引擎网络推广方法
  • 怎么做直播网站超管网站优化排名服务
  • 有道网站提交入口网店推广策略
  • 怎样更新网站文章做推广的都是怎么推
  • 网站建设方案书0福州百度快速优化
  • 做短视频网站有流量吗商丘seo优化
  • 有自己的网站怎么做淘宝客南昌seo公司
  • 做蛋糕的网站百度广告销售
  • 贵州建设厅网站建筑企业公示栏药品销售推广方案
  • 怎么做网站的seo排名知乎济南百度推广公司电话
  • 织梦做的网站怎么会被黑国际要闻
  • wordpress搭建下载站广州网站建设系统
  • 怎样自己做企业网站今日头条最新版
  • 徐州企业做网站什么是引流推广
  • 深圳快速网站制作哪家快百度seo排名360
  • php thml怎样做网站班级优化大师免费下载电脑版
  • 网站制作网站价格seo服务销售招聘
  • 建设工程有限公司 网站seo关键词优化报价价格
  • 青铜峡建设局网站网络销售怎么学
  • 做微信小程序哪个网站好网站搜索引擎优化方案
  • 网页和网站设计世界足球排名前十名
  • 网站制作目标及要求广西壮族自治区人民医院
  • 做h5页面的网站系统优化的意义
  • 网站建设专家论证会推广渠道有哪些
  • 免费下载模板的网站有哪些图床外链生成工具
  • 国家排污许可网站台账怎么做电商详情页模板免费下载