2017-05-09 82 views
0

是我的代码的一部分:它被设计成一个按钮点击后它是可见的。 这需要不同的时间量,所以我只是实现一个等待10秒。等待点击的元素变得可见 - 以下Chromedriver

有没有办法可以让这个更动态的,所以点击完成之后它是可见的?

在此先感谢!

亲切的问候

#go to the uploadtab 
--------------------- 
$searchBtnIris = $driver.FindElementByXPath('//*[@id="menuFormHome:j_id44_body"]/ul[3]/li[4]/a') 
Write-Host "Den ID van de zoekknop is $seachBtnIris" 
$searchBtnIris.Click(); 

Start-Sleep -s 10 

#click add button and select file to upload 
------------------------------------------- 
$searchBtnIris = $driver.FindElementByXPath('//*[@id="uploadFormPanel:upload:flashContainer"]') 
Write-Host "Den ID van de zoekknop is $seachBtnIris" 
$searchBtnIris.Click(); 

回答

0

这里有一个猜测

while (-not ($searchBtnIris)) { 
    try { 
     $searchBtnIris = $driver.FindElementByXPath('//*[@id="uploadFormPanel:upload:flashContainer"]') 
    } 
    catch { 
     Write-Verbose "Element not found" 
     Start-Sleep -Milliseconds 100    
    } 
} 

Write-Host "Den ID van de zoekknop is $seachBtnIris" 
$searchBtnIris.Click(); 
+0

嗨 这将返回:异常调用 “点击” 和 “0” 的说法(S):“陈旧元素参考:元没有连接到页面文件 – Steff

+0

仍是同样的错误,但感谢! – Steff

+0

你可以改变'写Verbose'到'写Host',看看有多少执行周期变救援人员到场呃,好吗? – gvee