Reputation: 99
I am able to inspect elements through appium using appium inspector, but the elements present on footer are not getting located due to which i am not able to get there xpath.
I tried using id fetched from source code, but again "unable to locate element" message is getting displayed when i ran my test script.
public static void main(String[] args) throws MalformedURLException, InterruptedException { AppiumDriver wd; DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("appium-version", "1.0"); capabilities.setCapability("platformName", "iOS"); capabilities.setCapability("platformVersion", "8.1"); capabilities.setCapability("deviceName", "iPhone 6"); capabilities.setCapability("app", "/Users/deepak/Library/Developer/Xcode/DerivedData/AceMobile-adoppngvthizceerrugpjdqlruyj/Build/Products/Debug-iphonesimulator/ACE Banker.app"); wd = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities); wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); Thread.sleep(10000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIATextField1")).click(); Thread.sleep(5000); ((MobileElement) wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIATextField1"))).setValue("[email protected]"); wd.findElement(By.name("Done")).click(); Thread.sleep(5000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASecureTextField1")).click(); ((MobileElement)wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASecureTextField1"))).setValue("ALMqAdmin123!"); wd.findElement(By.name("Done")).click(); //wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIAButton1")).click(); Thread.sleep(5000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIAButton1")).click(); Thread.sleep(5000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIASecureTextField1")).click(); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIASecureTextField1")).sendKeys("1111"); wd.findElement(By.name("Next")).click(); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIASecureTextField1")).click(); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIASecureTextField1")).sendKeys("1111"); wd.findElement(By.name("Done")).click(); Thread.sleep(5000);
/* Here we are sitting to scroll */
wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[8]")).click(); Thread.sleep(4000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[14]")).click(); Thread.sleep(4000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[20]")).click(); Thread.sleep(4000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[26]")).click(); Thread.sleep(4000); wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[32]")).click(); Thread.sleep(4000); //wd.findElement(By.xpath("//UIAApplication1/UIAWindow1/UIAScrollView1/UIAWebView1/UIASwitch[34]")).click(); Thread.sleep(5000);
/*After scroll this element is not getting located */ WebElement element = wd.findElement(By.id("ext-button-96"));
Above footer there is a scrollable screen.
Thanks
Upvotes: 0
Views: 934
Reputation: 11
Appium inspector & Ui automatorviewer will help to get the layout which is present on current android view.(all handles based on layouts).
If need to be find xpath which is not present on view try to scroll down on finding xpath,id(locators).
In scripts try to use scroll to text ot scroll to element.
Upvotes: 0