Guest User

Untitled

a guest
Sep 20th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.12 KB | None | 0 0
  1. package com.test;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.List;
  6. import java.util.concurrent.TimeUnit;
  7.  
  8. import org.openqa.selenium.By;
  9. import org.openqa.selenium.WebDriver;
  10. import org.openqa.selenium.WebElement;
  11. import org.openqa.selenium.interactions.Actions;
  12. import org.testng.Assert;
  13. import org.testng.AssertJUnit;
  14. import org.testng.Reporter;
  15. import org.testng.annotations.AfterClass;
  16. import org.testng.annotations.BeforeClass;
  17. import org.testng.annotations.Test;
  18.  
  19.  
  20.  
  21. public class APIWizardPage {
  22. public static WebDriver driver;
  23. GenericFunctions gfun = new GenericFunctions();
  24. public static String ConfigFilePath = "C:\\Users\\MaralayS\\workspace\\TestNG_selenium_suite\\config.properties";
  25. public static String POMFilePath = "C:\\Users\\MaralayS\\workspace\\TestNG_selenium_suite\\POMconfig.properties";
  26. String CurrentDir = System.getProperty("user.dir")+"";
  27. String Screenshot_Directory = CurrentDir+"\\Screenshot\\";
  28.  
  29. @Test (priority=8)
  30. public void After_Login_Check() throws IOException
  31. {
  32. String Screenshot_Title = "AfterLoginTitleCheck.png";
  33. System.out.println("current Dir "+CurrentDir);
  34. Reporter.log("After Login to the Wizard");
  35. String PageTitle = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "LoginTitle");
  36. try
  37. {
  38. Assert.assertEquals(driver.getTitle().trim(), PageTitle);
  39. Reporter.log("After Login Page title Correct");
  40. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  41. }
  42. catch(Exception e)
  43. {
  44. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  45. Reporter.log("Title is not Same as expected , Or may be its not loaded completely within 10 sec, Please Check");
  46. }
  47. }
  48.  
  49. @Test (priority=9)
  50. public void AfterLogin_VodafoneLogo() throws IOException
  51. {
  52. String Screenshot_Title = "AfterLoginLogoCheck.png";
  53. Reporter.log("After Login Logo Vodafone Circle Check");
  54. String LogoPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "LogoIcon");
  55. try
  56. {
  57. WebElement logo = driver.findElement(By.className(LogoPath));
  58. gfun.Highlight(logo,driver);
  59. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  60. }
  61. catch(Exception e)
  62. {
  63. try {
  64. Assert.assertEquals(true, false);
  65. }
  66. catch(Exception e1)
  67. {
  68. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  69. Reporter.log("After Login Vodafone Logo Not Found");
  70. }
  71. }
  72. }
  73.  
  74. @Test (priority=10)
  75. public void AfterLogin_API_Wizard_Text() throws IOException
  76. {
  77. String Screenshot_Title = "AfterLoginWizardTextCheck.png";
  78. Reporter.log("After Vodafone API Wizard Text Check");
  79.  
  80. String WizardTextPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "APIWizardText");
  81. try
  82. {
  83. String WizardText = driver.findElements(By.xpath(WizardTextPath)).get(0).getText();
  84. AssertJUnit.assertEquals(WizardText,"Vodafone API Wizard");
  85. Reporter.log("After Login - Vodafone API Wizard Text Found");
  86. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  87. }
  88. catch(Exception e)
  89. {
  90. System.out.println("Exception "+e);
  91. try {
  92. AssertJUnit.assertEquals(true, false);
  93. }
  94. catch(Exception e1)
  95. {
  96. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  97. Reporter.log("After Login Vodafone API Wizard Text Not Found");
  98. }
  99. }
  100. }
  101.  
  102. @Test (priority=11)
  103. public void AfterLogin_EmailLabel() throws IOException
  104. {
  105. String Screenshot_Title = "AfterLoginEmailLabel.png";
  106. Reporter.log("After Login Email Label Check");
  107. String EmailTitlepath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "EmailTitle");
  108. try
  109. {
  110. WebElement EmailTitle = driver.findElement(By.id(EmailTitlepath));
  111. gfun.Highlight(EmailTitle,driver);
  112. Thread.sleep(1000);
  113. Assert.assertEquals(true, true);
  114. Reporter.log("Email Label Found");
  115. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  116. }
  117. catch(Exception e)
  118. {
  119. try {
  120. Assert.assertEquals(true, false);
  121. }
  122. catch(Exception e1)
  123. {
  124. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  125. Reporter.log("After Login Email Title Not Found");
  126. }
  127. }
  128. }
  129.  
  130. @Test (priority=12)
  131. public void AfterLogin_EmailId() throws IOException
  132. {
  133. String Screenshot_Title = "AfterLoginEmailId.png";
  134. Reporter.log("After Login Email ID Check");
  135. String username = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "username");
  136. String EmailIDPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "EmailID");
  137.  
  138. try
  139. {
  140. WebElement EmailTitle = driver.findElement(By.id(EmailIDPath));
  141. gfun.Highlight(EmailTitle,driver);
  142. Thread.sleep(1000);
  143. Assert.assertEquals(username,EmailTitle.getText());
  144. Reporter.log("Email ID Found as used for login");
  145. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  146. }
  147. catch(Exception e)
  148. {
  149. try {
  150. Assert.assertEquals(true, false);
  151. }
  152. catch(Exception e1)
  153. {
  154. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  155. Reporter.log("After Login Email Title Not Found");
  156. }
  157. }
  158.  
  159. }
  160.  
  161. @Test (priority=13) //(timeOut=0,priority=1)
  162. public void APISpecification() throws IOException
  163. {
  164. String Screenshot_Title = "ApiSpecification.png";
  165. Reporter.log("ApiSpecification Check");
  166. String APISpecification = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ApiSpecification");
  167. try
  168. {
  169. WebElement EmailTitle = driver.findElement(By.xpath(APISpecification));
  170. gfun.Highlight(EmailTitle,driver);
  171. Thread.sleep(1000);
  172. Reporter.log("Api Specification Found");
  173. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  174. }
  175. catch(Exception e)
  176. {
  177. try {
  178. Assert.assertEquals(true, false);
  179. }
  180. catch(Exception e1)
  181. {
  182. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  183. Reporter.log("ApiSpecification Not Found");
  184. }
  185. }
  186. }
  187.  
  188. @Test (priority=14) //(timeOut=0,priority=1)
  189. public void LoadEditor() throws IOException
  190. {
  191. String Screenshot_Title = "LoadEditor.png";
  192. Reporter.log("Load Editor Check");
  193. String LoadEditor = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Load");
  194. try
  195. {
  196. WebElement Load = driver.findElement(By.id(LoadEditor));
  197. gfun.Highlight(Load,driver);
  198. Thread.sleep(1000);
  199. Reporter.log("Load Editor Found");
  200. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  201. }
  202. catch(Exception e)
  203. {
  204. try {
  205. Assert.assertEquals(true, false);
  206. }
  207. catch(Exception e1)
  208. {
  209. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  210. Reporter.log("Load Editor Not Found");
  211. }
  212. }
  213. }
  214.  
  215. @Test (priority=15) //Ignore //(timeOut=0,priority=1)
  216. public void SwaggerEditor() throws IOException
  217. {
  218. String Screenshot_Title = "SwaggerEditor.png";
  219. Reporter.log("SwaggerEditor Check");
  220. String SwaggerEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SwaggerEditor");
  221. try
  222. {
  223. WebElement SwaggerEditor= driver.findElement(By.id(SwaggerEditorPath));
  224. gfun.Highlight(SwaggerEditor,driver);
  225. Reporter.log("Swagger Editor Found");
  226. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  227. }
  228. catch(Exception e)
  229. {
  230. try {
  231. Assert.assertEquals(true, false);
  232. }
  233. catch(Exception e1)
  234. {
  235. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  236. Reporter.log("Swagger Editor Not Found");
  237. }
  238. }
  239. }
  240.  
  241. @Test (priority=16) //(timeOut=0,priority=1)
  242. public void ValidateEditor() throws IOException
  243. {
  244. String Screenshot_Title = "ValidateEditor.png";
  245. Reporter.log("ValidateEditor Check");
  246. String ValidateEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ValidateEditor");
  247. try
  248. {
  249. WebElement ValidateEditor= driver.findElement(By.id(ValidateEditorPath));
  250. gfun.Highlight(ValidateEditor,driver);
  251. Reporter.log("Validate Editor Found");
  252. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  253. }
  254. catch(Exception e)
  255. {
  256. try {
  257. Assert.assertEquals(true, false);
  258. }
  259. catch(Exception e1)
  260. {
  261. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  262. Reporter.log("Validate Editor Not Found");
  263. }
  264. }
  265. }
  266.  
  267. @Test (priority=17) //(timeOut=0,priority=1)
  268. public void ExportOAS_YAML() throws IOException
  269. {
  270. String Screenshot_Title = "ExportOAS_YAML.png";
  271. Reporter.log("Export OAS Yaml Check");
  272. String OutputEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_YAML");
  273. try
  274. {
  275. WebElement OutputEditor= driver.findElement(By.id(OutputEditorPath));
  276. gfun.Highlight(OutputEditor,driver);
  277. Reporter.log("Export OAS Yaml Found");
  278. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  279. }
  280. catch(Exception e)
  281. {
  282. try {
  283. Assert.assertEquals(true, false);
  284. }
  285. catch(Exception e1)
  286. {
  287. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  288. Reporter.log("Export OAS Yaml Not Found");
  289. }
  290. }
  291. }
  292.  
  293. @Test (priority=18) //(timeOut=0,priority=1)
  294. public void ExportOAS_JSON() throws IOException
  295. {
  296. String Screenshot_Title = "ExportOAS_JSON.png";
  297. Reporter.log("Export OAS JSON Check");
  298. String OutputEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_JSON");
  299. try
  300. {
  301. WebElement OutputEditor= driver.findElement(By.id(OutputEditorPath));
  302. gfun.Highlight(OutputEditor,driver);
  303. Reporter.log("Export OAS JSON Found");
  304. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  305. }
  306. catch(Exception e)
  307. {
  308. try {
  309. Assert.assertEquals(true, false);
  310. }
  311. catch(Exception e1)
  312. {
  313. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  314. Reporter.log("Export OAS JSON Not Found");
  315. }
  316. }
  317. }
  318.  
  319. @Test (priority=19) //(timeOut=0,priority=1)
  320. public void ReviewEditor() throws IOException
  321. {
  322. String Screenshot_Title = "ReviewEditor.png";
  323. Reporter.log("ReviewEditor Check");
  324. String ReviewEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ReviewEditor");
  325. try
  326. {
  327. WebElement ReviewEditor= driver.findElement(By.id(ReviewEditorPath));
  328. gfun.Highlight(ReviewEditor,driver);
  329. Reporter.log("Review Editor Found");
  330. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  331. }
  332. catch(Exception e)
  333. {
  334. try {
  335. Assert.assertEquals(true, false);
  336. }
  337. catch(Exception e1)
  338. {
  339. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  340. Reporter.log("Review Editor Not Found");
  341. }
  342. }
  343. }
  344.  
  345. @Test (priority=20) //(timeOut=0,priority=1)
  346. public void Update_LoadEditor() throws IOException
  347. {
  348. String Screenshot_Title = "Update.png";
  349. Reporter.log("Update in Load Editor Check");
  350. String UpdatePath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Update");
  351. try
  352. {
  353. WebElement Update= driver.findElement(By.id(UpdatePath));
  354. gfun.Highlight(Update,driver);
  355. Reporter.log("Update in Load Editor Found");
  356. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  357. }
  358. catch(Exception e)
  359. {
  360. try {
  361. Assert.assertEquals(true, false);
  362. }
  363. catch(Exception e1)
  364. {
  365. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  366. Reporter.log("Update in load Editor Not Found");
  367. }
  368. }
  369. }
  370.  
  371. @Test (priority=21) //(timeOut=0,priority=1)
  372. public void SampleSwagger_LoadEditor() throws IOException
  373. {
  374. String Screenshot_Title = "SampleSwagger.png";
  375. Reporter.log("SampleSwagger in Load Editor Check");
  376. String SampleSwaggerPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SampleSwagger");
  377. try
  378. {
  379. WebElement SampleSwagger= driver.findElement(By.xpath(SampleSwaggerPath));
  380. gfun.Highlight(SampleSwagger,driver);
  381. Reporter.log("Sample Swagger in Load Editor Found");
  382. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  383. }
  384. catch(Exception e)
  385. {
  386. try {
  387. Assert.assertEquals(true, false);
  388. }
  389. catch(Exception e1)
  390. {
  391. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  392. Reporter.log("Sample Swagger in load Editor Not Found");
  393. }
  394. }
  395. }
  396.  
  397. @Test (priority=22) //(timeOut=0,priority=1)
  398. public void LoadSwagger_LoadEditor() throws IOException
  399. {
  400. String Screenshot_Title = "LoadSwagger.png";
  401. Reporter.log("LoadSwagger in Load Editor Check");
  402. String LoadSwaggerPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "LoadSwagger");
  403. try
  404. {
  405. WebElement LoadSwagger= driver.findElement(By.xpath(LoadSwaggerPath));
  406. gfun.Highlight(LoadSwagger,driver);
  407. Reporter.log("Load Swagger in Load Editor Found");
  408. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  409. }
  410. catch(Exception e)
  411. {
  412. try {
  413. Assert.assertEquals(true, false);
  414. }
  415. catch(Exception e1)
  416. {
  417. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  418. Reporter.log("Load Swagger in load Editor Not Found");
  419. }
  420. }
  421. }
  422.  
  423. @Test (priority=23) //(timeOut=0,priority=1)
  424. public void SelectfileLabel_LoadEditor() throws IOException
  425. {
  426. String Screenshot_Title = "SelectFileLabel.png";
  427. Reporter.log("File Select Label in Load Editor Check");
  428. String FileSelectedLabelPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SelectFile");
  429. try
  430. {
  431. WebElement FileSelected= driver.findElement(By.xpath(FileSelectedLabelPath));
  432. gfun.Highlight(FileSelected,driver);
  433. Reporter.log("FileSelected: Label in Load Editor Found");
  434. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  435. }
  436. catch(Exception e)
  437. {
  438. try {
  439. Assert.assertEquals(true, false);
  440. }
  441. catch(Exception e1)
  442. {
  443. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  444. Reporter.log("FileSelected: Label in load Editor Not Found");
  445. }
  446. }
  447. }
  448.  
  449. @Test (priority=24) //(timeOut=0,priority=1)
  450. public void SelectfileValueInitial_LoadEditor() throws IOException
  451. {
  452. String Screenshot_Title = "SelectFileValueInitial.png";
  453. Reporter.log("SelectFileValue before select should be blank - Check");
  454. String FileSelectedPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "FileSelected");
  455. try
  456. {
  457. WebElement FileSelected= driver.findElement(By.id(FileSelectedPath));
  458. gfun.Highlight(FileSelected,driver);
  459. int length_beforefileselected = FileSelected.getText().length();
  460. Assert.assertEquals(length_beforefileselected, 0);
  461. Reporter.log("FileSelected: Value is blank in Load Editor Found");
  462. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  463. }
  464. catch(Exception e)
  465. {
  466. try {
  467. Assert.assertEquals(true, false);
  468. }
  469. catch(Exception e1)
  470. {
  471. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  472. Reporter.log("FileSelected: Label in load Editor Not Found");
  473. }
  474. }
  475. }
  476.  
  477. @Test (priority=25) //(timeOut=0,priority=1)
  478. public void Clear_LoadEditor() throws IOException
  479. {
  480. String Screenshot_Title = "Clear_loadEditor.png";
  481. Reporter.log("Clear in Load Editor - Check");
  482. String ClearPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Clear");
  483. try
  484. {
  485. WebElement Clear= driver.findElement(By.xpath(ClearPath));
  486. gfun.Highlight(Clear,driver);
  487.  
  488. Reporter.log("Clear in Load Editor Found");
  489. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  490. }
  491. catch(Exception e)
  492. {
  493. try {
  494. Assert.assertEquals(true, false);
  495. }
  496. catch(Exception e1)
  497. {
  498. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  499. Reporter.log("Clear in load Editor Not Found");
  500. }
  501. }
  502. }
  503.  
  504.  
  505.  
  506. @Test (priority=26)
  507. public void Case1_UpdateTest() throws IOException
  508. {
  509. String Screenshot_Title = "Case1_UpdateTest.png";
  510. Reporter.log("Update the Swagger Test - Check");
  511. String UpdatePath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Update");
  512. String UpdateTextPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "UpdateText");
  513.  
  514. try
  515. {
  516. WebElement LoadSwagger = driver.findElement(By.id(UpdatePath));
  517. LoadSwagger.click();
  518. Thread.sleep(500);
  519. WebElement AlertText = driver.findElement(By.id(UpdateTextPath));
  520. gfun.Highlight(AlertText, driver);
  521. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  522. String alerttext = AlertText.getText();
  523. Assert.assertEquals(alerttext,"JSON definition parsed successfully");
  524. Thread.sleep(2000);
  525. Reporter.log("Update Alert popup Successfully");
  526. }
  527. catch(Exception e)
  528. {
  529. try {
  530. Assert.assertEquals(true, false);
  531. }
  532. catch(Exception e1)
  533. {
  534. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  535. Reporter.log("Update alert popup Not Found");
  536. }
  537. }
  538. }
  539.  
  540.  
  541.  
  542. @Test (priority=27)
  543. public void Case2_SwaggerEditorCheck_Default() throws IOException, InterruptedException
  544. {
  545. String Screenshot_Title = "Case2_SwaggerEditorCheck_Default.png";
  546. Reporter.log(" SwaggerEditor Default - Check");
  547. String SwaggerEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SwaggerEditor");
  548. String SwaggerEditor_Left_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SwaggerEditor_leftclass");
  549.  
  550. try
  551. {
  552. WebElement SwaggerEditor = driver.findElement(By.id(SwaggerEditorPath));
  553. SwaggerEditor.click();
  554. Thread.sleep(5000);
  555. // Getting All the Div's//
  556. List<WebElement> DIVs= driver.findElements(By.tagName("div"));
  557.  
  558. for(WebElement we : DIVs)
  559. {
  560. String classname = we.getAttribute("class");
  561. if((classname!=""||classname.length()>0) && (classname.equalsIgnoreCase("tab-pane")))
  562. {
  563. Thread.sleep(2000);
  564. try{
  565. driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
  566. }catch(Exception e)
  567. {
  568. Assert.assertEquals(1,1);
  569. System.out.println("Switching to iframe content");
  570. }
  571. Thread.sleep(1000);
  572. }
  573. }
  574. }
  575. catch(Exception e)
  576. {
  577. try {
  578. //Assert.assertEquals(true, false);
  579. }
  580. catch(Exception e1)
  581. {
  582. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  583. Reporter.log("Case2 Swagger Editor Default Left and Right Container is not empty visibile - not Found");
  584. }
  585. }
  586.  
  587. WebElement SE_Left = driver.findElement(By.className(SwaggerEditor_Left_Path));
  588. gfun.Highlight(SE_Left, driver);
  589.  
  590. Thread.sleep(1000);
  591. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  592.  
  593. String left = SE_Left.getText();
  594. Assert.assertNotEquals(left.length(),0);
  595.  
  596. driver.switchTo().defaultContent();
  597. Thread.sleep(2000);
  598. Reporter.log("Swagger Editor opened with proper contents - Successfully");
  599. }
  600.  
  601.  
  602. @Test (priority=28)
  603. public void Case3_SwaggerValidatorCheck_Default() throws IOException
  604. {
  605. String Screenshot_Title = "Case3_SwaggerValidatorCheck_Default.png";
  606. Reporter.log(" Swagger Validator Default - Check");
  607. String SwaggerValidatorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ValidateEditor");
  608. String SwaggerValidatorClassPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ValidateEditorClass");
  609.  
  610. try
  611. {
  612. WebElement SwaggerValidator = driver.findElement(By.id(SwaggerValidatorPath));
  613. SwaggerValidator.click();
  614. Thread.sleep(2000);
  615.  
  616. WebElement SwaggerValidator_Class = driver.findElement(By.className(SwaggerValidatorClassPath));
  617. String Source = SwaggerValidator_Class.getText();
  618. Assert.assertNotEquals(Source,"ERROR");
  619. Assert.assertNotEquals(Source,"error");
  620. Reporter.log("Swagger Validator Default is visible with no error present - PASS");
  621. }
  622. catch(Exception e)
  623. {
  624. try {
  625. Assert.assertEquals(true, false);
  626. }
  627. catch(Exception e1)
  628. {
  629. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  630. Reporter.log("Swagger Validator Default is visible with error - FAIL");
  631. }
  632. }
  633. }
  634.  
  635.  
  636. @Test (priority=29)
  637. public void Case4_ExportOAM_YAML_Check_Default() throws IOException
  638. {
  639. String Screenshot_Title = "Case4_ExportOAM_YAML_Check_Default.png";
  640. Reporter.log("Case4_ExportOAM_YAML_Check_Default - Check");
  641. String ExportOAM_YAML_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_YAML");
  642. String ExportOAM_YAML_Class_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_YAML_id");
  643. String Alert1_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlert1");
  644. String Alert1_Button = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlertOKButton");
  645.  
  646. try
  647. {
  648. Thread.sleep(5000);
  649. WebElement ExportOAMPATH = driver.findElement(By.id(ExportOAM_YAML_Path));
  650. ExportOAMPATH.click();
  651. Thread.sleep(2000);
  652.  
  653. WebElement ExportOAMPATH_Class = driver.findElement(By.id(ExportOAM_YAML_Class_Path));
  654. String Source = ExportOAMPATH_Class.getText();
  655. if(Source.contains("swagger"))
  656. {
  657. Assert.assertEquals(true,true);
  658. Reporter.log("Export OAS Yaml file contents are visible and non Empty");
  659. }
  660. else
  661. {
  662. Assert.assertEquals(false,true);
  663. Reporter.log("Export OAS Yaml file contents is not visble or is Empty");
  664. }
  665.  
  666. try
  667. {
  668. WebElement alert1 = driver.findElement(By.id(Alert1_Path));
  669. WebElement alert1button = driver.findElement(By.id(Alert1_Button));
  670. alert1button.click();
  671. Assert.assertEquals(false, true);
  672. Reporter.log("For Valid Swagger - Alert is coming [Update Swagger is not in the proper format] - FAIL");
  673. }
  674. catch(Exception e)
  675. {
  676. Reporter.log("For Valid Swagger , Alert [Update Swagger is not in the proper format] is not present");
  677. Assert.assertEquals(true,true);
  678. }
  679. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  680. Reporter.log("Case4 Export OAS Yaml Default is visible with contents - shown Successfully");
  681. }
  682. catch(Exception e)
  683. {
  684. try {
  685. Assert.assertEquals(true, false);
  686. }
  687. catch(Exception e1)
  688. {
  689. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  690. Reporter.log("Case4 Export OAS Yaml Default is not visible ");
  691. }
  692. }
  693. }
  694.  
  695.  
  696. @Test (priority=30)
  697. public void Case5_ExportOAM_JSON_Check_Default() throws IOException
  698. {
  699. String Screenshot_Title = "Case5_ExportOAM_JSON_Check_Default.png";
  700. Reporter.log("Case5_ExportOAM_JSON_Check_Default - Check");
  701. String ExportOAM_JSON_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_JSON");
  702. String ExportOAM_JSON_Class_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_JSON_id");
  703. String Alert1_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlert1");
  704. String Alert1_Button = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlertOKButton");
  705.  
  706. try
  707. {
  708. Thread.sleep(5000);
  709. WebElement ExportOAMPATH = driver.findElement(By.id(ExportOAM_JSON_Path));
  710. ExportOAMPATH.click();
  711. Thread.sleep(2000);
  712.  
  713. WebElement ExportOAMPATH_Class = driver.findElement(By.id(ExportOAM_JSON_Class_Path));
  714. String Source = ExportOAMPATH_Class.getText();
  715. if(Source.contains("swagger"))
  716. {
  717. Assert.assertEquals(true,true);
  718. Reporter.log("Export OAS JSON file contents are visible and non Empty");
  719. }
  720. else
  721. {
  722. Assert.assertEquals(false,true);
  723. Reporter.log("Export OAS JSON file contents is not visble or is Empty");
  724. }
  725.  
  726. try
  727. {
  728. WebElement alert1 = driver.findElement(By.id(Alert1_Path));
  729. WebElement alert1button = driver.findElement(By.id(Alert1_Button));
  730. alert1button.click();
  731. Reporter.log("For Valid Swagger OAS JSON, Alert [Update Swagger is not in the proper format] should not present");
  732. Assert.assertEquals(false,true);
  733. }
  734. catch(Exception e)
  735. {
  736. Reporter.log("For Valid Swagger OAS JSON, Alert [Update Swagger is not in the proper format] should not present");
  737. Assert.assertEquals(true,true);
  738. }
  739. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  740. Reporter.log("Case5 Export OAS JSON Default is visible with contents - shown Successfully");
  741. }
  742. catch(Exception e)
  743. {
  744. try {
  745. Assert.assertEquals(true, false);
  746. }
  747. catch(Exception e1)
  748. {
  749. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  750. Reporter.log("Case5 Export OAS Yaml Default is not visible ");
  751. }
  752. }
  753. }
  754.  
  755.  
  756. @Test (priority=31)
  757. public void Case6_Review_Check_Default() throws IOException
  758. {
  759. String Screenshot_Title = "Case6_Review_Check_Default.png";
  760. Reporter.log("Case6_Review_Check_Default - Check");
  761. String ReviewEditor_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ReviewEditor");
  762. String Submit_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Submit");
  763.  
  764. try
  765. {
  766. Thread.sleep(5000);
  767. WebElement ReviewPATH = driver.findElement(By.id(ReviewEditor_Path));
  768. ReviewPATH.click();
  769. Thread.sleep(2000);
  770.  
  771. try
  772. {
  773. WebElement Submit = driver.findElement(By.id(Submit_Path));
  774. Reporter.log("Review Container - Submit present");
  775. gfun.Highlight(Submit, driver);
  776. Assert.assertEquals(true,true);
  777. }
  778. catch(Exception e)
  779. {
  780. Reporter.log("Review Container - Submit not present");
  781. Assert.assertEquals(false,true);
  782. }
  783. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  784. Reporter.log("Case6 Review with submit button for Default case - shown Successfully");
  785. }
  786. catch(Exception e)
  787. {
  788. try {
  789. Assert.assertEquals(true, false);
  790. }
  791. catch(Exception e1)
  792. {
  793. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  794. Reporter.log("Case6 Review with submit button is not visible ");
  795. }
  796. }
  797. }
  798.  
  799.  
  800.  
  801. @Test (priority=32)
  802. public void Logout() throws IOException
  803. {
  804. String Screenshot_Title = "logout.png";
  805. Reporter.log("Logout Check");
  806. String Logout_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Logout");
  807. try
  808. {
  809. WebElement Logout = driver.findElement(By.id(Logout_Path));
  810. Actions actions = new Actions(driver);
  811. gfun.Highlight(Logout,driver);
  812. Reporter.log("Logout Found");
  813. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  814. actions.moveToElement(Logout);
  815. actions.click();
  816. actions.build().perform();
  817. }
  818. catch(Exception e)
  819. {
  820. try {
  821. Assert.assertEquals(true, false);
  822. }
  823. catch(Exception e1)
  824. {
  825. GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
  826. Reporter.log("Logout Not Found");
  827. }
  828. }
  829. }
  830.  
  831. @BeforeClass
  832. public void BeforeClass() throws IOException
  833. {
  834. driver = gfun.InitiateDriver(new File(ConfigFilePath));
  835. String URL = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "BaseURL");
  836. String Timeout = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "TimeOut");
  837. int time = Integer.parseInt(Timeout);
  838. driver.get(URL);
  839. driver.manage().timeouts().implicitlyWait(time,TimeUnit.SECONDS);
  840. String Title = driver.getTitle();
  841. if(Title.contains("4")||Title.contains("503")||Title.length()<=0)
  842. {
  843. Reporter.log("Page is not opening , Some issue with the URL or Internet Connectivity slowness , Server not respond. Kindly Check and retry");
  844. System.out.println("Page is not responding"+driver.getTitle());
  845. AssertJUnit.assertEquals(driver.getTitle(), "Vodafone API Wizard");
  846. }
  847.  
  848. /**
  849. * Login Again
  850. */
  851. String username = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "username");
  852. String password = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "password");
  853.  
  854. String Email_ID_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Email_Id_TextBox");
  855. String Password_ID_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Password_TextBox");
  856.  
  857. String Login_Button = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "LoginButton");
  858. String Logout_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Logout");
  859.  
  860. try
  861. {
  862. Actions actions = new Actions(driver);
  863. Thread.sleep(5000);
  864. WebElement EmailID = driver.findElement(By.id(Email_ID_Path));
  865. EmailID.sendKeys(username);
  866.  
  867.  
  868. WebElement Password = driver.findElement(By.id(Password_ID_Path));
  869. Password.sendKeys(password);
  870.  
  871. WebElement LoginButton = driver.findElement(By.xpath(Login_Button));
  872.  
  873. actions.moveToElement(LoginButton);
  874. actions.click();
  875. actions.build().perform();
  876.  
  877.  
  878. Thread.sleep(2000);
  879. driver.navigate().to(URL);
  880. Thread.sleep(5000);
  881. }
  882. catch(Exception e)
  883. {
  884. System.out.println("Exception "+e);
  885. try {
  886. AssertJUnit.assertEquals(true, false);
  887. }
  888. catch(Exception e1)
  889. {
  890. Reporter.log("Login Unsuccessfull, Please check user is registered or not");
  891. }
  892. }
  893. }
  894.  
  895. @AfterClass
  896. public void CloseBrowser() throws IOException
  897. {
  898. driver.close();
  899. driver.quit();
  900. }
  901. }
Add Comment
Please, Sign In to add comment