等待頁面某元素載入完成的方法

2021-08-26 23:14:50 字數 656 閱讀 2557

一、先在allocationcommon中寫個方法

// 等待頁面某元素載入完成(引數:type元素定位型別、by該型別對應的定位值)

public static void load(string type, string by) else if("id".equals(type)) else if("name".equals(type)) else if("cssselector".equals(type)) else if("linktext".equals(type)) else

}

二、在element中呼叫此方法

public static webelement allocationbutton(webdriver webdriver){

string xpath = "(//button[@type='button'])[4]";

machinecommon.load("xpath",xpath);

webelement = webdriver.findelement(by.xpath(xpath));

return webelement;

三、在具體的test中,呼叫此元素

machineelement.allocationbutton(driver).click();

jquery載入頁面的方法 頁面載入完成就執行

1 function 2 document ready function 3 window.onload function html 為點選,且頁面需要引用jquery的js檔案 一般的載入頁面時呼叫js方法如下 window.onload function 這段 會在整個頁面的document全部...

幾種等待併發執行緒全部完成的方法

學習到如下幾種方法 1 對於單個的執行緒,可以採用future.get 的方法,任務執行完畢後才能拿到結果。2 對於多個執行緒,可以採用executor.awaittemination 的方法,偽 如下所示 for int i 0 i n i executor.execute task i exec...

兩種頁面載入等待效果的實現

第一種,當開啟乙個新的頁面時,這個頁面的載入時間可能會比較長,可以用以下js實現頁面等待效果,將該js匯入載入的頁面即可使用 獲取瀏覽器頁面可見高度和寬度 var pageheight document.documentelement.clientheight,pagewidth document....