python包可以在selenium上轻松运行javascript代码片段
seleniumjs的Python项目详细描述
硒
v1.0.11 Beta
使用selenium.webdriver轻松执行javascript代码,无需执行脚本()。目前支持5个dom对象,而且很快就会有更多的对象加入到项目中。
当前支持dom对象
安装
使用pip安装
pip install seleniumjs
安装到项目目录的步骤
- 将项目克隆到项目目录
- 运行命令
python3 setup.py install
用法
控制台类
fromseleniumjsimportConsoleconsole=Console(driver)console.time()console.log('Hello World')console.log('This is seleniumjs')console.timeEnd()
警告:
Console
不支持assert
方法位置类
fromseleniumjsimportLocationlocation=Location(driver)print(location.href)location.href='https://github.com/shashankrnr32/SeleniumJS#usage'print(location.hash)
存储类
fromseleniumjsimportSessionStoragesessionStorage=SessionStorage(driver)sessionStorage.setItem('key','value')print(sessionStorage.length)
info:使用
LocalStorage
而不是SessionStorage
历史类
fromseleniumjsimportHistoryhistory=History(driver)print(history.length)history.back()print(history.length)
navigator类
fromseleniumjsimportNavigatornavigator=Navigator(driver)print(navigator.appCodeName)print(navigator.language)
警告:
Navigator
不支持geolocation
(尚未)
测试
这个包正在开发中,测试在Google Chrome和Mozilla Firefox中完成。该项目将在edge测试,opera将在未来发布。通过在safari中进行测试,为这个项目做出贡献。
许可证
麻省理工学院免费许可证由Shashank Sharma
本项目不受硒的资助/支持。要了解更多有关硒的信息,请访问here