Esempio n. 1
0
 @Test(priority = 4, dataProvider = "dataProviderForMusicBlog")
 public void musicBlogTest(TestParameters testParams)
     throws UnsupportedEncodingException, InterruptedException, MalformedURLException {
   if (m1 == null || m1.size() == 0) throw new SkipException("Map is empty");
   String URL = "http://one.airtel.in/iportal?dg=5&lang=en";
   BaseUtil.launchUrl(URL, false);
   // BaseUtil.scrollingToBottomofAPage();
   By locater =
       By.xpath(
           "//div[@id='paginateOuter']//div[@class='cardOuter']/article[contains(@class,'card music-card')]//div[@class='add-on']//p[@class='link']/a[contains(.,'Listen Now')]");
   while (!BaseUtil.checkIfElementPresent(locater, 1)) {
     BaseUtil.scrollingToBottomofAPage();
   }
   BaseUtil.scrollingToElementofAPage(locater);
   // WebElement elem = BaseUtil.getElementWhenClickable(locater);
   WebElement elemButton = BaseUtil.getElementWhenVisible(locater);
   String whole = BaseUtil.getText(elemButton).trim();
   String ButtonURL = BaseUtil.getAttribute(elemButton, "onclick");
   System.out.println("News URL:\t" + ButtonURL);
   System.out.println("BlogText:\t" + whole);
   By locater1 =
       By.xpath(
           "//div[@id='paginateOuter']//div[@class='cardOuter']/article[contains(@class,'card music-card')]//div[@class='add-on']//p[@class='text']");
   WebElement elemText = BaseUtil.getElementWhenVisible(locater1);
   String wholeTitle = BaseUtil.getText(elemText).trim();
   System.out.println("BlogTitle:\t" + wholeTitle);
   elemButton.click();
   Pattern pattern = Pattern.compile(".*'([^']*)'.*");
   Matcher matcher = pattern.matcher(ButtonURL);
   String p2 = "";
   if (matcher.matches()) {
     String url = matcher.group(1);
     URL url1 = new URL(url);
     String query = url1.getQuery();
     // Decode two time query url
     String p1 = URLDecoder.decode(query, "UTF-8");
     p2 = URLDecoder.decode(p1, "UTF-8");
     System.out.println("BlogUrl==>" + p2);
   }
   Reporter.log("Verify POD Blog url with the api result", m1.get(wholeTitle), p2, "Pass");
   Assert.assertEquals(
       p2.trim().contains(m1.get(wholeTitle)), true, "Verify POD Blog url with the api result");
   BaseUtil.browserBackButton();
 }
Esempio n. 2
0
 @Test(priority = 3, dataProvider = "dataProviderForMusicViewAll")
 public void musicViewALLTest(TestParameters testParams)
     throws UnsupportedEncodingException, InterruptedException, MalformedURLException {
   String URL = "http://one.airtel.in/iportal?dg=5&lang=en";
   BaseUtil.launchUrl(URL, false);
   // BaseUtil.scrollingToBottomofAPage();
   By locater =
       By.xpath(
           "//div[@class='cardOuter']/article[contains(@class,'card music-card')]//div[@class='heading']/span[@class='view-all' and contains(.,'View All')]/a");
   while (!BaseUtil.checkIfElementPresent(locater, 1)) {
     BaseUtil.scrollingToBottomofAPage();
   }
   BaseUtil.scrollingToElementofAPage(locater);
   // WebElement elem = BaseUtil.getElementWhenClickable(locater);
   WebElement elemheading = BaseUtil.getElementWhenVisible(locater);
   String whole = BaseUtil.getText(elemheading).trim();
   String HeadingURL = BaseUtil.getAttribute(elemheading, "onclick");
   System.out.println("News URL:\t" + HeadingURL);
   System.out.println("BlogText:\t" + whole);
   elemheading.click();
   Pattern pattern = Pattern.compile(".*'([^']*)'.*");
   Matcher matcher = pattern.matcher(HeadingURL);
   String p2 = "";
   if (matcher.matches()) {
     String url = matcher.group(1);
     URL url1 = new URL(url);
     String query = url1.getQuery();
     // Decode two time query url
     String p1 = URLDecoder.decode(query, "UTF-8");
     p2 = URLDecoder.decode(p1, "UTF-8");
     System.out.println("BlogUrl==>" + p2);
   }
   Reporter.log("Verify POD Blog url with the api result", externalLinkUrl, p2, "Pass");
   Assert.assertEquals(
       p2.trim().contains(externalLinkUrl), true, "Verify POD Blog url with the api result");
   BaseUtil.browserBackButton();
 }