您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > AI人工智能 > selenium webdriverAPI-python
Python-seleniumwebdriverAPIMethodsdefinedhere:__init__(self,executable_path='IEDriverServer.exe',capabilities=None,port=0,timeout=30,host=None,log_level=None,log_file=None)quit(self)add_cookie(self,cookie_dict)Addsacookietoyourcurrentsession.optionalkeys-path,domain,secure,expirydriver.add_cookie({'name':'foo','value':'bar'})driver.add_cookie({'name':'foo','value':'bar','path':'/'})driver.add_cookie({'name':'foo','value':'bar','path':'/','secure':True})back(self)Goesonestepbackwardinthebrowserhistory.driver.back()close(self)Closesthecurrentwindow.driver.close()create_web_element(self,element_id)Createsawebelementwiththespecifiedelement_id.delete_all_cookies(self)Deleteallcookiesinthescopeofthesession.driver.delete_all_cookies()delete_cookie(self,name)Deletesasinglecookiewiththegivenname.driver.delete_cookie('my_cookie')execute(self,driver_command,params=None)Sendsacommandtobeexecutedbyacommand.CommandExecutor.-driver_command:Thenameofthecommandtoexecuteasastring.-params:Adictionaryofnamedparameterstosendwiththecommand.:Returns:Thecommand'sJSONresponseloadedintoadictionaryobject.execute_async_script(self,script,*args)AsynchronouslyExecutesJavaScriptinthecurrentwindow/frame.-script:TheJavaScripttoexecute.-\*args:AnyapplicableargumentsforyourJavaScript.driver.execute_async_script('document.title')execute_script(self,script,*args)SynchronouslyExecutesJavaScriptinthecurrentwindow/frame.:Args:-script:TheJavaScripttoexecute.-\*args:AnyapplicableargumentsforyourJavaScript.driver.execute_script('document.title')file_detector_context(*args,**kwds)Overridesthecurrentfiledetector(ifnecessary)inlimitedcontext.Ensurestheoriginalfiledetectorissetafterwards.withwebdriver.file_detector_context(UselessFileDetector):someinput.send_keys('/etc/hosts'):Args:-file_detector_class-Classofthedesiredfiledetector.Iftheclassisdifferentfromthecurrentfile_detector,thentheclassisinstantiatedwithargsandkwargsandusedasafiledetectorduringthedurationofthecontextmanager.-args-Optionalargumentsthatgetpassedtothefiledetectorclassduringinstantiation.-kwargs-Keywordarguments,passedthesamewayasargs.find_element(self,by='id',value=None)'Private'methodusedbythefind_element_by_*methods.Usethecorrespondingfind_element_by_*insteadofthis.:rtype:WebElementfind_element_by_class_name(self,name)Findsanelementbyclassname.:Args:-name:Theclassnameoftheelementtofind.driver.find_element_by_class_name('foo')find_element_by_css_selector(self,css_selector)Findsanelementbycssselector.:Args:-css_selector:Thecssselectortousewhenfindingelements.driver.find_element_by_css_selector('#foo')find_element_by_id(self,id_)Findsanelementbyid.:Args:-id\_-Theidoftheelementtobefound.driver.find_element_by_id('foo')find_element_by_link_text(self,link_text)Findsanelementbylinktext.:Args:-link_text:Thetextoftheelementtobefound.driver.find_element_by_link_text('SignIn')find_element_by_name(self,name)Findsanelementbyname.:Args:-name:Thenameoftheelementtofind.driver.find_element_by_name('foo')find_element_by_partial_link_text(self,link_text)Findsanelementbyapartialmatchofitslinktext.:Args:-link_text:Thetextoftheelementtopartiallymatchon.driver.find_element_by_partial_link_text('Sign')find_element_by_tag_name(self,name)Findsanelementbytagname.:Args:-name:Thetagnameoftheelementtofind.driver.find_element_by_tag_name('foo')find_element_by_xpath(self,xpath)Findsanelementbyxpath.:Args:-xpath-Thexpathlocatoroftheelementtofind.driver.find_element_by_xpath('//div/td[1]')find_elements(self,by='id',value=None)'Private'methodusedbythefind_elements_by_*methods.Usethecorrespondingfind_elements_by_*insteadofthis.:rtype:listofWebElementfind_elements_by_class_name(self,name)Findselementsbyclassname.:Args:-name:Theclassnameoftheelementstofind.driver.find_elements_by_class_name('foo')find_elements_by_css_selector(self,css_selector)Findselementsbycssselector.:Args:-css_selector:Thecssselectortousewhenfindingelements.driver.find_elements_by_css_selector('.foo')find_elements_by_id(self,id_)Findsmultipleelementsbyid.:Args:-id\_-Theidoftheelementstobefound.driver.find_elements_by_id('foo')find_elements_by_link_text(self,text)Findselementsbylinktext.:Args:-link_text:Thetextoftheelementstobefound.driver.find_elements_by_link_text('SignIn')find_elements_by_name(self,name)Findselementsbyname.:Args:-name:Thenameoftheelementstofind.driver.find_elements_by_name('foo')find_elements_by_partial_link_text(self,link_text)Findselementsbyapartialmatchoftheirlinktext.:Args:-link_text:Thetextoftheelementtopartialmatchon.driver.find_element_by_partial_link_text('Sign')find_elements_by_tag_name(self,name)Findselementsbytagname.:Args:-name:Thetagnametheusewhenfindingelements.driver.find_elements_by_tag_name('foo')find_elements_by_xpath(self,xpath)Findsmultipleelementsbyxpath.:Args:-xpath-Thexpathlocatoroftheelementstobefound.driver.find_elements_by_xpath(//div[contains(@class,'foo')])forward(self)Goesonestepforwardinthebrowserhistory.driver.forward()get(self,url)Loadsawebpageinthecurrentbrowsersession.get_cookie(self,name)Getasin
三七文档所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
本文标题:selenium webdriverAPI-python
链接地址:https://www.777doc.com/doc-4455741 .html