2017-01-25 9 views
0

を使用してdatePickerで年を選択する要素が隠されているため、アンドロイドアプリの日付ピッカーで非表示要素を選択/クリックしようとしています。私はさまざまなアプローチを試しましたが、望みの結果が得られていませんでした。日付ピッカーでは、選択されたデフォルトは現在の年(2017)です。前の年(2016)を選択すると正常に動作します。 クリックする前にフォーカスするためにスワイプする必要があるので、1992年のような年を選択するにはどうすればよいですか?セレン、appiumとC#

コード:

_driver.FindElement(By.Id("com.appzonegroup.dejavuandroid.zoneRevamp:id/dob")).Click(); 

      int ThisYear = Int32.Parse(_driver.FindElement(By.Id("com.appzonegroup.dejavuandroid.zoneRevamp:id/date_picker_year")).Text); 
      String RegistrableYear = Convert.ToString(ThisYear - 25); 
      _driver.FindElement(By.Id("com.appzonegroup.dejavuandroid.zoneRevamp:id/date_picker_year")).Click(); 

      IWebElement ElementToClick = _driver.FindElement(By.XPath("//android.widget.TextView[@text=" +"'"+RegistrableYear+"'"+"]")); 
      Actions ActionBuilder = new Actions(_driver); 
      Actions HoverAction = ActionBuilder.MoveToElement(ElementToClick).MoveByOffset(GetX(10), GetY(10)).Click(); 
      HoverAction.Build().Perform(); 

enter image description here enter image description here

エラーログ

> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.TextView[@text='1992']","context":"","multiple":false}] 
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='1992']","context":"","multiple":false}} 
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION 
> info: [debug] [BOOTSTRAP] [debug] Got command action: find 
> info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.TextView[@text='1992'] using XPATH with the contextId: multiple: false 
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"Could not find an element using supplied strategy. "} 
> info: [debug] Condition unmet after 20354ms. Timing out. 
> info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Could not find an element using supplied strategy. "},"sessionId":"f4ed7681-9932-42e3-9490-3cc2b556cd11"} 

答えて

0

使用scrollto()メソッドと、それはあなたが選択したい日付にスクロールするのに役立ちます。

+0

C#バインディングにsctollto()はありません。 – kehinde