12 2018 档案
摘要:一、等待 1.is_display:hidden属性,元素隐藏 2.is_selected:bool = element.is_selected() radio单选框 checkbox多选框 3.选中所有选项: els = driver.find_elements_by... for i in el
阅读全文
摘要:一、显式等待: 1.WebDriverWait(): from selenium.webdriver.support.ui import WebDriverWait element = WebDriverWait(driver, 10, 0.5).until(lambda x: x.find_ele
阅读全文
摘要:一、内建函数: 1.内建函数:比如sum:sum(list) 2.查看内建函数:dir(__builtins__) 二、匿名函数: b = lambda x : x * x c = lambda x, y: x + y 三、不定长参数: def printinfo(arg1, *args): pri
阅读全文
摘要:一、跳过测试用例 1.无条件跳过,在用例上面加一个装饰器:@unittest.skip(提示语句) 2.条件为True时跳过,加装饰器:@unittest.skipIf((条件),(提示语句)) 3.条件为False时跳过,加装饰器:@unittest.skipUnless((条件),(提示语句))
阅读全文
摘要:1.help(unittest)查看帮助文档。 2.try: except: 3.退出登录的简便方法:driver.delete_all_cookies()
阅读全文
摘要:一、定位方法: 1.#id,如:#account 2.点class:.table.table-form,多重属性,空格直接改成点 3.标签直接写标签名字 4.其他属性用中括号:[name='kw'][其他属性] 5.层级关系用>符号:table>body>tr 6.form#form>span>in
阅读全文
摘要:1.//双斜杠相对路径 2.//标签[@属性 and @属性],//iframe[@id="updater"] 3.xpath定位class多重属性:@class=直接复制多重属性 4.文本定位://*[text()="忘记密码"] 5.文本有换行的,通过父元素,直接/text()://*[@cla
阅读全文
摘要:一、下拉框select 1.下拉框select: # select标签且option子标签的才适用以下方法 from selenium.webdriver.support.select import Select select = driver.find_element_by_id("nr") Se
阅读全文
摘要:一、定位并切入iframe: 1.a = driver.find_element_by_tag_name("iframe") driver.switch_to.frame(a) 2.多层iframe嵌套: 使用switch_to切入两次 3.如果iframe有id, 可直接通过id切入: drive
阅读全文
摘要:一、元素定位: id、name、class_name、tag_name、link_text、partial_link_text、xpath、css_selector link_text:driver.find_element_by_link_text("百度新闻").click() xpath-->
阅读全文
摘要:一.环境搭建:Selenium2.53.6+Firefox46以下+python3.6 1.selenium安装:pip install selenium==2.53.6。 2.FireFox安装:链接:https://pan.baidu.com/s/1fFubTnczPScYUZxBzeJGCg
阅读全文

浙公网安备 33010602011771号