@Before public void setUp() throws Exception { Properties prop = new Properties(); prop.load(AndroidText4.class.getResourceAsStream("/config/config.properties")); prop.load(AndroidText4.class.getResourceAsStream("/config/Text4.properties")); propertyID = prop.getProperty("propertyID"); campaignID = prop.getProperty("campaignID"); entityID = prop.getProperty("entityId"); windowID = prop.getProperty("windowId"); orderLinesID = JSON.GetOrderLines(campaignID); ClickCount = JSON.GetClick(campaignID, orderLinesID); ImpressionCount = JSON.GetImpression(campaignID, orderLinesID); System.out.println("ClickCount before test: " + ClickCount); System.out.println("ImpressionCount before test: " + ImpressionCount); }
@Test public void testAndroidText4() throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); capabilities.setCapability("deviceName", "CB5A1LYY6N"); capabilities.setCapability("automationName", "Selendroid"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("app", "/home/justice/Downloads/app-debug.apk"); capabilities.setCapability("app-package", "com.sony.csx.ad.mobile"); capabilities.setCapability("app-activity", "com.sony.csx.ad.mobile.MainActivity"); AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); // input EntityID AppiumSAMAPI.InputEntityID(driver, entityID); // input WindowID AppiumSAMAPI.InputWindowID(driver, windowID); // load ad AppiumSAMAPI.ClickLoadAD(driver); driver.context("WEBVIEW_0"); System.out.println(driver.getPageSource()); System.out.println( driver .findElement(By.xpath("//div[contains(@class, 'text_description_content')]")) .getText()); System.out.println( driver.findElement(By.xpath("//div[contains(@class, 'text_title_content')]")).getText()); assertTrue( "Selenium Auto Test for Text4 Description not found!!", driver.getPageSource().contains("Selenium Auto Test for Text4 Description")); assertTrue( "Selenium Auto Test for Text4 Description not found!!", driver .findElement(By.xpath("//div[contains(@class, 'text_description_content')]")) .getText() .equals("Selenium Auto Test for Text4 Description")); assertTrue( "Selenium Auto Test for Text4 Title not found!!", driver .findElement(By.xpath("//div[contains(@class, 'text_title_content')]")) .getText() .equals("Selenium Auto Test for Text4 Title")); assertTrue( "textad.css not found!!", driver.getPageSource().contains("/dev2/ad/csx/csxwin/css/textad.css")); // click impression AppiumSAMAPI.ClickImpression(driver); // driver.findElementByLinkText("Selenium Auto Test for Text1 Title").click(); // driver.findElementByPartialLinkText("Selenium Auto Test for Text1 // Title").sendKeys("Keys.ENTER"); // driver.context("WEBVIEW_0"); // driver.findElement(By.xpath("//div[contains(@class, 'text_title_content')]")).click(); Thread.sleep(5000); assertTrue( "ClickCount does not match!!" + "It should be" + ClickCount + 1 + " But now is " + ClickCount, JSON.GetClick(campaignID, orderLinesID) == ClickCount); assertTrue( "ImpressionCount does not match" + "It should be" + ImpressionCount + 1 + " But now is " + ImpressionCount, JSON.GetImpression(campaignID, orderLinesID) == ImpressionCount + 1); ClickCount = JSON.GetClick(campaignID, orderLinesID); ImpressionCount = JSON.GetImpression(campaignID, orderLinesID); System.out.println("ClickCount after test: " + ClickCount); System.out.println("ImpressionCount after test: " + ImpressionCount); driver.quit(); }