driver.find_element_by_id('login_button').click()#点击登录按钮
time.sleep(3)
接着,判断好友空间是否设置了权限,通过判断是否存在元素ID:QM_OwnerInfo_Icon
try:
driver.find_element_by_id('QM_OwnerInfo_Icon')
b = True
except:
b = False

如果有权限能够访问到说说页面,那么定位元素和数据,并解析:
if b == True:
driver.switch_to.frame('app_canvas_frame')
this driver is registered with the fbdev subsystem, and is responsible for managing the graphics layer frame buffer. driver creates /dev/fb0 as the device node. application can open this device node to open the driver and negotiate parameters with the driver through frame buffer ioctls. application maps driver allocated buffers in the application memory space and fills them for the driver to display.。ssl terminator h.323 cdm (content distribution manager) iad router access gateway content router content service module。checkboxes = driver.find_elements_by_css_selector(‘input[type=checkbox]‘)。
stime = driver.find_elements_by_css_selector('.c_tx.c_tx3.goDetail')
for con,sti in zip(content,stime):
data = {
# 'qq':qq,
'time':sti.text,
'shuos':con.text
}
print(data)
假设页面中有一个表单,用户填写了数据但却没有保存提交,他直接点击了刷新按钮,这时候就可以使用onbeforeunload事件来提示用户“数据没有保存”,这样就给哪些忘记提交或不小心点击到页面其他链接的用户一个取消的机会。6.while大循环中使用epoll_wait返回活跃的事件,每个事件开启一个线程处理(线程中主要是解析页面,保存页面,url处理等),程结束的时候可能会开启新的任务。 一、jquery解析json数据格式: 使用这种方法,你必须在ajax请求中设置参数: 1 datatype: "json" 获取通过回调函数返回的数据并解析得到我们想要的值,看源码: 代码如下: jquery.ajax(。
pages = driver.page_source
soup = BeautifulSoup(pages,'lxml')
最后,我们尝试一下获取Cookie,使用get_cookies():
cookie = driver.get_cookies()
cookie_dict = []
for c in cookie:
ck = "{0}={1};".format(c['name'],c['value'])
cookie_dict.append(ck)
i = ''
for c in cookie_dict:
i += c
print('Cookies:',i)
另外,再介绍两个Selenium的常用方法:
●保存屏幕截图:
driver.save_screenshot('保存的文件路径及文件名')
●执行JS脚本:
driver.execute_script("JS代码")
对于Selenium更加详细的操作和使用,推荐一本书《selenium webdriver(python)第三版》网上可以搜索到。
【推荐】JMeter接口自动化与性能测试案例实践
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-116032-2.html
我国是一个爱好和平的国家
看你的反应