Python+sele
山大王110
这个作者很懒,什么都没留下…
展开
-
selenium之页面跳转导致元素定位失败(click)
1.产生场景,执行下述语句,click之后,页面发生变化,原页面被覆盖重新打开新页面,导致元素定位不到。报错1:stale element reference: element is not attached to the page document报错2:NoSuchFrameException: Message: no such frame 报错2:查找不到元素driver...原创 2018-11-14 11:18:30 · 12987 阅读 · 1 评论 -
查找元素中的内容
self.driver.find_element_by_xpath('/html/body/div/div/div/div/div[1]/h3').text原创 2018-11-14 17:27:46 · 181 阅读 · 0 评论 -
Python+selenuim 自动化测试 文件上传
转自:https://blog.csdn.net/huilan_same/article/details/52439546测试上传文件功能时,弹出文件选择框来选择正确的文件上传。本次用到的页面由于没有注意上传按钮的标签是input,因此查了大量关于非input上传的材料,在这里做个记录。1.有input标签这种比较简单,定位到元素后,直接sendkeys,输入要上传文件的绝对地址。...转载 2018-11-16 11:59:33 · 905 阅读 · 0 评论 -
Python+selenuim下载文件
1.Chrome下载文件profile = webdriver.ChromeOptions()driver = webdriver.Chrome(chrome_options=profile) 2.Firefox下载文件profile = webdriver.FirefoxProfile()driver = webdriver.Firefox(firefox_profile...原创 2018-11-19 18:16:06 · 207 阅读 · 0 评论 -
Python中解决中文解码编码问题
问题:b_msg":"\u8bf7\u5148\u767b\u5f55,运行时,产生非中文,需要通过转码来解决。对内容进行解码:decode('unicode_escape')原创 2018-12-04 14:40:24 · 8894 阅读 · 0 评论 -
遇到的一些问题解决方法
1.使用requests,模拟访问网站时,遇到安全证书的时候verify = False2.遇到r.text查看相应内容为乱码的时候,使用r.content.decode('utf-8')(其中“utf-8”与response headers中的Content-Type中的charset一致)# -*- coding:utf-8 -*-import requestsre = reque...原创 2018-12-04 17:59:37 · 280 阅读 · 0 评论 -
Python+selenuim调用配置文件
Python3中调用configparser模块中的类ConfigParser,将配置文件写在配置路径下,实现调用配置参数# coding=utf-8import configparserimport osfrom selenium import webdriverclass Browser_engine(object): def get_value(self): ...原创 2019-06-03 17:00:25 · 134 阅读 · 0 评论 -
selenuim定位
定位红框中的文本内容,此处用到了find_elements_by_css_selector。组合定位元素表示,标签为啊,class值为KSSActionServer的元素。content = self.driver.find_element_by_class_name('tabularContents').find_elements_by_css_selector('a[class="K...原创 2019-09-27 18:05:42 · 285 阅读 · 0 评论