2016-09-20 10 views
3

Ranorexでは、要素の存在を待つ方法を見つけましたが、要素の待機方法がわかりません。要素を待つ方法はRanorexに見えますか?

enter image description here

私は同じことをしたいが、私は、要素が表示されるまで待ちたいです。残念ながら、WaitForステートメントの可能な値はExistNot Existです。そして私の場合、テストは信頼できません。なぜなら、要素の存在にもかかわらずクリックが開始されても、まだ表示されないからです。

どうすればいいですか?

ウェブ要素について

答えて

0

、アイテムが存在するかどうかを知ることは困難である可視である、等

Iは、私の例では、それらを比較することによって、DOMページの位置と幅を使用して、スライドメニュー位置を信頼性を達成幅は次のようになります。

Public Function IsMenuVisible() As Boolean 
     Dim menuVisible As Boolean 

     'Get page position and width 
     Dim pageXPosition As Integer = repo.WebPage.Self.Element.ScreenLocation.X 
     Dim pageWidth As Integer = repo.WebPage.Self.Element.ScreenRectangle.Width 
     'Get configuration menu position and width 
     Dim menuXPosition As Integer = repo.WebPage.Menu.Self.Element.ScreenLocation.X 
     Dim menuWidth As Integer = repo.WebPage.Menu.Self.Element.ScreenRectangle.Width 

     'If menu top right location is >= web page size (out of screen) 
     If menuXPosition + menuWidth > pageXPosition + pageWidth Then 
      Report.Info(String.Format("Configuration menu is hidden (menuXPositon = {0}, pageXPosition = {1}, pageWidth = {2}, menuWidth = {3}).", menuXPosition, pageXPosition, pageWidth, menuWidth)) 
      menuVisible = False 
     Else 
      Report.Info("Configuration menu is currently visible.") 
      menuVisible = True 
     End If 

     Return menuVisible 
    End Function 

私の例では、メニューはページの右側にあります。必要に応じて変更してください。次のようにメニューが表示されるように

その後は、ループ回数を簡単なユーザコードを実行します。

 Public Sub WaitForMenuToAppear() 
     Dim retries As Integer = WaitForMenuToAppearRetries 
     While Not IsMenuVisible() AndAlso retries > 0 
      retries -= 1 
      Report.Info(String.Format("Waiting for configuration menu to be visible ({0}).", retries)) 
      Delay.Duration(1000) 
     End While 

     If Not IsMenuVisible() Then 
      Throw New RanorexException(String.Format("Menu did not appear within '{0}' seconds.", WaitForMenuToAppearRetries)) 
     Else 
      Report.Info("Menu is visible.") 
     End If 
    End Sub 

私はスライディングが常に表示されているので、これをしなければなりませんでした。 Ranorex Spyのハイライト機能を使用すると、赤い矩形がWebページの表示領域外に描画されます。

例を完了するために私はあなたに残します。

・ホープこれはあなたが要素を待つVisibleプロパティを使用することができます...

+0

Ranorexが最後に読むことができるように、それを直接的に統合するプロセスが進行中であるこの[Ranorexユーザーボイス記事](http://uservoice.ranorex.com/forums/150109-ideas-to-improve-ranorex/suggestions/17162687-create-function-for-wait-for-visible-and-wait) -ために) – Sup3rHugh

0

を支援します。

DateTime start = DateTime.Now; 

while (Repository.Element.Visible) 
{    
    Delay.Seconds(1); 

    if(System.DateTime.Now.Subtract(start).TotalSeconds > MaxWaitTime) 
    {     
     Validate.Fail(""); 
    } 
} 
0

あなたのレポパス[@visible='true']にこの要素を追加し、WaitForExistsを使用することができます。

repo.elementInfo.WaitForExists(SearchTimeOut) 
関連する問題