javascript执行

1.selenium常用方法:

判断元素是否存在:is_display

获取元素的文本:webelement.text

获取浏览器的标题:driver.title

获取元素的属性:webelement.get_attribute('属性名称')

2.javascript实现方法:

打开新的浏览器窗口:window.open(url)

浏览器内部宽度:window.innerWidth

浏览器内部高度:window.innerHeight

浏览器整体宽度:window.outerWidth

浏览器整体高度:window.outerHeight

浏览器滚动条:

window.scrollTo(0,1000)

window.scrollBy(0,1000)

页面中的滚动条

document.getElementById('styleShow').scrollTop=10000

非浏览器类型的滚动条:

document.getElementsByid(id)[0].scrollTop='1000'

获取当前url:location.href()

更改当前url:location.assign('http://127.0.0.1:5000/')

刷新:location.reload()


获取当前标题:document.title

输入文本值:document.getElementsByid(id)[0].value=''

操作标签:document.getElementsByid(id)[0].click()

更改元素属性值:<先获取元素的属性:document.getElementById('vip').style

再将属性值进行更改

document.getElementById('vip').style.visibility='visible'>

alert(document.getElementById('vip').style.visibility)

js =return document.getElementById('vip').style.visibility

driver.excute_script(js)

你可能感兴趣的:(javascript执行)