selenium定位经验总结

python3 + selenium + iedriverpython

一、pageA跳转到pageB,pageB全部元素被封在<frameset>中,跳转过来后要先找到这个<frameset>标签才能定位其中的元素。web

先找到<frameset>标签:app

WebDriverWait(self.ieDriver, 500, 0.5).until(工具

  EC.presence_of_element_located((By.TAG_NAME, 'frameset')))spa

二、window窗口上传文件图片能够借助工具AutoIt V3:调试

;ControlFocus("title","text",controlID) Edit1=Edit instance 1
ControlFocus("选择要加载的文件", "","Edit1")blog


; Wait 10 seconds for the Upload window to appear
WinWait("[CLASS:#32770]","",10)图片


; Set the File name text on the Edit fieldelement

ControlSetText("选择要加载的文件", "", "Edit1", "E:\Project\python\swebid\swebid_ztb\add_bidding_registion\邵武招标登记.xlsx")
Sleep(2000)get

; Click on the Open button

ControlClick("选择要加载的文件", "","Button1");

三、frame多的状况下,能够调试的时候控制台输入webDriver.find_elements_by_tag_name('frame')/webDriver.find_elements_by_tag_name('iframe').get_attribuate('name')来查找目前所在的哪一个frame

相关文章
相关标签/搜索