UI自動(dòng)化測(cè)試面試題_3_Selenium Python API

Webdriver 屬性有以下:

driver.current_url 獲取當(dāng)前頁(yè)面的URL 地址

driver.name 獲取瀏覽器的名稱(chēng)

driver.title 獲取瀏覽器的Ttitle

driver.page_source

Webdriver 的方法有

driver.back()

driver.forward()

driver.close()

driver.refresh()

driver.quite()

driver.get(“URL”)

driver.switch_to_alert()

driver.switch_to_frame(“frame_name”)

WebElement 接口:

element.text 獲取元素的文本值

element.clear()

element.click()

element.submit()

element.get_attribute()

element.is_displayed()

element.is_selected()

element.send_keys(“value”)

element.is_enabled()

Select 類(lèi):

首先要 創(chuàng)建 Select 對(duì)象才能 調(diào)用他的屬性和方法,

Select(select_element).options 返回的是所有的下拉選項(xiàng)

Select(select_element).select_by_index(1) 選擇第一個(gè)選項(xiàng)

Select(select_element).select_by_value(value”) 按照Value 進(jìn)行選擇

Select(select_element).select_by_visible_text("Text”) 按照text 進(jìn)行選擇

如果想比較list 里的值是否和預(yù)期的一樣 要用 assertListEqual(Expect_valeu,act_value)

Alert 類(lèi)

首先要生成Alert 對(duì)象

alert=driver.switch_to_alert()

屬性有 alert.text ,獲取 彈出框的文本。

方法有以下:

alert.accept()

alert.dismiss()

alert.send_keys(“value”)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容