这是一个selenium easy库,它有简单的语法构建硒.all这些东西在后台运行,我们只调用函数。这对初学者来说太容易了
easyselenium的Python项目详细描述
易溶硒
让我们来处理无聊的事情吧!
=================
easyselenium被写在selenium的顶部,以使selenium对于现成的内置函数来说更容易,只需要调用函数并传递争论。全部时间延迟和webdriver等待selectfindpingxpath将在后端完成的额外工作。 不要使用时间延迟
作者:Ankit Kothari Apache 2.0 license。在
优势
- 1.简单易用的语法,不需要记住整个selenium语法和google它。它将根据您的需要:(浏览器=ie/chrome/firefox)
- 2.不需要下载chrmoe/firefox/it的驱动程序,它会自动将accc下载到你的缓存/你想要的路径上。在
- 3.所有的命令都有显式等待,所以不需要使用时间睡眠和减慢您的代码或元素找不到错误。它将等待找到所有元素/页面。在
- 4.选择部分文本选项
- 5.同时管理窗口/Javascript警报。在
- 6.调试将逐行打印内部内容。在
- 7.自动读取元素的文本和值,并在调试模式下打印并在打包列表中重新运行。在
文件
从easy selenium进口*
1。打开浏览器()
with optional arguments open_browser(browser='chrome/firefox/ie',headless=True/False,debug=True/False) By default by default time: Explicit wait is 50 sec for every function Change from passing(timeout=1)## open_browser(headless=False,,browser='chrome',debug=False,path=cache memory to download drivers/or your customised path)
2.连接现有浏览器(url、会话id)
^{pr2}$3.打开url(url='https://step2success.in')
with optional arguments open_url(url='https://step2success.in',new_tab=False)new_tab= True/False (open in new tab or same)
4.窗把手(no=1)
窗口句柄(title='google')
To switch to your popup or another tab window ()
5.开关框(no=1或name='mainframe')
To switch to iframe or frame with no or name switch_frame(no=1 / name='mainframe'/id='name'/css='btn-danger'/ xpath='class=btn-pop'/xpath='//[div[3]/article/div[1]]')
6.单击(text='submit'或image='imagepath'或id='submit'或css='send'或xpath='this')
根据iamge/Text或xpath单击buton
with optional arguments click_on(no=1 / name='mainframe'/id='name'/css='btn-danger'/ xpath='class=btn-pop'/xpath='//[div[3]/article/div[1]]')repeat=True/False (True- To double click on item)
7.mosue_hover(text='submit'或image='imagepath'或id='submit'或css='send'或xpath='this')
To hover mouse on avascript element instead of click
8.发送文本(text='your text',id='submit'或css='send'或xpath='this')
```sh with optional arguments send_text(no=1 / name='mainframe'/id='name'/css='btn-danger'/ xpath='class=btn-pop'/xpath='//[div[3]/article/div[1]]') with_enter=True/False (True-To enter after type text)
9.选择下拉列表(option='option to select'with id='submit'或css='send'或xpath='this')
To select option in dropdown with partial text select_dropdown(no=1 / name='mainframe'/id='name'/css='btn-danger'/ xpath='class=btn-pop'/xpath='//[div[3]/article/div[1]]')
10.读取文本(id='submit'或css='send'或xpath='this')
To read text from element/multiple elements It is samrt enough to automatically detect if single or multiple element is present Value/Text is present Then return you a packed list of elemnts containing text,value and session_id read_text(no=1 / name='mainframe'/id='name'/css='btn-danger'/ xpath='class=btn-pop'/xpath='//[div[3]/article/div[1]]')
11.关闭窗口(no=1或name='yahoo')
To switch and close the provided window optional switch_to=0 to switch to this window after closing
12.windows_警报(text='NA',with_enter=False)
To send text or enter to accept to windows authentication
13.警报(text='yes'/'no'/'custom'/blank阅读文本)
To accept/decline/send text/read text from alert box
14.第页来源()
To print raw HTML
示例:
import time from easyselenium import * import time open_browser(path="chromedriver.exe",browser='chrome',debug=True)#open_broswer(browser='firefox')#open_broswer(browser='ie')#open_broswer(browser='chrome',headless=True) open_url(url="https://step2success.in/registration-page-demo/") open_url(url="https://step2success.in/iframe-demo/",new_tab=True) window_handle(no=0) send_text(text='Ankit',id='first_name') send_text(text='Kothari',id='last_name',with_enter=True) select_dropdown(option='What is your Birthdate?',id='dropdown')#click_on(text='REGISTER')#click_on(id='register') time.sleep(3) window_handle(no=1) switch_frame(no=0) read_text(href='#') click_on(text='Follow On Twitter') window_handle(no=2)#close_window(no=2)
- 项目
标签: