2017-11-17 5 views
0

私は、リンクやテキストをクリックすることができましたが、私はAndroidのAppiumAndroid Appium Chromeボタンクリックまたはタップしませんか?

public void testcheck() { 
    System.out.println("Select"); 
    //<a id="vivKo" href="javascript:void(0);" class="btn btn- green vivKo at_vivKo"> 
    //<span class="text">vivKo</span> 
    // <i class="fa fa-chevron-right"></i> </a> 
    //driver.findElementByXPath("//span[contains(., \"" + vivKo + "\")]").click(); 
    WebElement vova = (WebElement) driver.findElementByXPath("//*[@id=vivKo']"); 
    TouchAction ta = new TouchAction(driver); 
    ta.longPress(vova); 
    //WebElement vova = (WebElement) driver.findElementByXPath("//*[@id='vivKo']"); 
    driver.findElement(By.xpath("//*[@id='vivKo']")).click(); 
    WebElement elementToClick = driver.findElement(By.xpath("//*[@id='vivKo']")); 
    Actions actions = new Actions(driver); 
    new WebDriverWait(driver, 60).until(ExpectedConditions.visibilityOf(vova)); 
    actions.moveToElement(elementToClick).click().build().perform(); 

エラーでChromeを使用してボタンをクリックすることはできません:FAILED:あなたがいない要素があることがわかっている場合

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (180, 630) 
(Session info: chrome=62.0.3202.84) 
(Driver info: chromedriver=2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 237 milliseconds 
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43' 
System info: host: 'AMAC02T90QRGTFM', ip: '192.168.14.180', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144' 
Driver info: io.appium.java_client.android.AndroidDriver 
Capabilities [{deviceScreenSize=1440x2960, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=9887fc35525a485333, platform=LINUX, deviceUDID=9887fc35525a485333, desired={platformVersion=7.0, browserName=Chrome, platformName=Android, deviceName=Vovchik}, platformVersion=7.0, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, browserName=Chrome, javascriptEnabled=true, deviceModel=SM-G950U, platformName=Android, deviceManufacturer=samsung}] 
Session ID: 10923751-6fb6-48d1-b61d-50be29f84770 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
at 
+0

[Selenium Web Driver&Javaの複製可能な要素がポイントでクリック可能ではありません。要素はポイント(36,72)でクリックできません。他の要素はクリックを受け取ります:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el) – DebanjanB

+0

ありがとう!どのように私はscrollTo()がうまくいきませんでした。 –

答えて

0

をtestcheck画面に表示されますが、それでもドライバで取得できる場合は、クリックする前にスワイプ(100 pxなど)してください。もちろん

int x = element.getLocation().getX(); 
int y = element.getLocation().getY(); 
new TouchAction(driver) 
    .press(x, y) 
    .waitAction(ofMillis(500)) 
    .moveTo(x, y+100) 
    .release() 
    .perform(); 

は、アカウントの画面サイズに取って、より正確なピクセルシフトを計算することができます。

関連する問題