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

通辽企业网站建设怎么设置域名

通辽企业网站建设,怎么设置域名,上海网站建设排名公司哪家好,wordpress 自定义登陆页面# 随手小记 场景:测试百度: 点击新闻,跳转到新的窗口,找到输入框,输入“hello,world" 等到输入框的内容是hello,world, 这里有个错误,少了一个] 后来就实现了错误截图的功能,可以参考 …

# 随手小记

场景:测试百度:

点击新闻,跳转到新的窗口,找到输入框,输入“hello,world"

等到输入框的内容是hello,world, 这里有个错误,少了一个]

后来就实现了错误截图的功能,可以参考

//input[@id='ww'"
 WebDriverWait(chrome_driver,10).until(expected_conditions.text_to_be_present_in_element_value((By.XPATH,"//input[@id='ww'"),"hello,world"))

完整代码 

# 通过xpath定位,By.XPATH
# xpath是一门在xml文档中查找信息的语言
# 为什么使用xpath可以定位htmk
# html文档的结构和标签嵌套遵循XML的基本规则,因此XPath可以有效的用于html文档中定位元素。XPath
# 从而实现定位
# xpath定位html的基本原则是,将html文档视为xml文档,并且使用Xpath表达式来描述元素的位置关系
# 选择特定的元素或者元素集合# xpath可以通过相对路径和绝对路径去定位元素,绝对路径从html根节点开始算,相对路径从任意节点开始
import time
import osfrom selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditionschrome_driver = webdriver.Chrome()
try:# 1.从根节点开始选取:绝对路径chrome_driver.get("https://www.baidu.com")chrome_driver.maximize_window()# 类变量  绝对路径# chrome_driver.find_element(By.XPATH,)chrome_driver.implicitly_wait(10)chrome_driver.find_element(By.XPATH,'/html[1]/body[1]/div[1]/div[1]/div[3]/a[1]').click()# 切换窗口all_window = chrome_driver.window_handleschrome_driver.switch_to.window(all_window[1])# driver.findElement(By.xpath("//img[@alt='百度新闻']"))WebDriverWait(chrome_driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,"//img[@alt='百度新闻']")))assert 'news' in chrome_driver.current_urlprint(chrome_driver.current_url)time.sleep(5)# 从任意节点开始取,//div 列出所有的div标签web_eles = chrome_driver.find_elements(By.XPATH,'//div')print(web_eles)print(len(web_eles))# 这个网站取练手杠杠滴# https://iviewui.com/view-ui-plus/component/form/form#选取当前父节点是input的下面的a元素web_a = chrome_driver.find_elements(By.XPATH,'//div/a')print(len(web_a))# 根据属性选取# 1.使用id属性定位chrome_driver.find_element(By.XPATH,"//input[@id='ww']").send_keys("hello,world")WebDriverWait(chrome_driver,10).until(expected_conditions.text_to_be_present_in_element_value((By.XPATH,"//input[@id='ww']"),"hello,world"))chrome_driver.find_element(By.XPATH,"//input[@id='ww']").clear()time.sleep(5)except Exception as e:# 截图存储的文件夹screenshot_dir = os.path.join(os.getcwd(), "screenshot")# 如果目录不存在,则创建if not os.path.exists(screenshot_dir):os.makedirs(screenshot_dir)# 获取当前截图目录下所有的 PNG 文件existing_screenshots = [f for f in os.listdir(screenshot_dir) if f.endswith(".png")]# 计算新的截图编号new_index = len(existing_screenshots) + 1  # 从1开始累加# 生成新的截图路径screenshot_path = os.path.join(screenshot_dir, f"{new_index}.png")# 发生异常时截图chrome_driver.save_screenshot(screenshot_path)print(f"操作失败,已截图: {screenshot_path}")print(f"错误信息: {e}")finally:# 关闭浏览器chrome_driver.quit()

最后的截图

 


文章转载自:

http://Aick6e3E.bLfgh.cn
http://dtDEK8OY.bLfgh.cn
http://b7xFa25B.bLfgh.cn
http://WyzxGU0B.bLfgh.cn
http://kuDe8miX.bLfgh.cn
http://sZqFQxfu.bLfgh.cn
http://hOGC8Fu8.bLfgh.cn
http://0dlU4heP.bLfgh.cn
http://Nsdufmxy.bLfgh.cn
http://F5w8aFz7.bLfgh.cn
http://rkjL055o.bLfgh.cn
http://s7oFiloJ.bLfgh.cn
http://LhHgxChC.bLfgh.cn
http://u9Imx18z.bLfgh.cn
http://vtzkI0Fj.bLfgh.cn
http://gJDuMS57.bLfgh.cn
http://aqjxcPBc.bLfgh.cn
http://qKBhxijB.bLfgh.cn
http://ORXgkxSQ.bLfgh.cn
http://lXfsx25c.bLfgh.cn
http://Nz4XLVx3.bLfgh.cn
http://VVXIUwiV.bLfgh.cn
http://td5984uQ.bLfgh.cn
http://9Fy5NYGb.bLfgh.cn
http://ZaszCmyb.bLfgh.cn
http://vY8zTDJV.bLfgh.cn
http://o79ptTCX.bLfgh.cn
http://txDCKkKc.bLfgh.cn
http://DjGw745f.bLfgh.cn
http://yOWDUY7r.bLfgh.cn
http://www.dtcms.com/wzjs/712262.html

相关文章:

  • 想查客户信息做网站网站建设标书样本
  • 怎么做网站301转向浚县网站建设
  • 网站开发从零到上线php手机wap网站源码
  • 松原建设局网站网络平台宣传方式有哪些
  • 中国建设银行对公网站做网站运营需要学什么条件
  • 龙南建设局网站微商城开发lk华网天下价格合适
  • 承包活应该上什么平台天津seo排名公司
  • 找合伙做网站的什么平台可以发网推广
  • 医药医疗行业网站建设wordpress升级教程
  • 邵阳 做网站公司专业仿站网站建设
  • 郑州好的网站建站广州云建站模板
  • 深圳建网站兴田德润很好怎么接app推广的单子
  • 网站建设费计入什么科目比较好江苏水利工程建设局网站
  • 电子商务基础网站建设wordpress4.9.6 主题安装
  • 网站建设百家号河北辛集市城乡建设管理局网站
  • php个人网站源码下载中国菲律宾混血
  • 小江网站建设公司自建app平台
  • wordpress用户发文章数量福州seo管理
  • 廉江网站制作帮别人做网站开票开什么税目
  • 建筑工程教育网官方网站宜昌网站建设设计
  • 网站开发网页制作教程上网登录页网址
  • 济南建站模板网站页面多大合适
  • 网站建设公司北京华网天下实惠西宁市城市道路建设规划网站
  • 网站建设属于什么经营范围网络营销与市场营销的关系?
  • 昆明网站建设服务网站权重是怎么提升的
  • 四川专业网站建设推广购物网站前端浮动特效怎么做
  • 建设产品网站课程设计进货渠道网
  • 网站建设公司软件开wordpress 交流群
  • 兰州网站定制公司网站建设课程大纲
  • 建手机版网站代理猫