Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.test;
- import java.io.File;
- import java.io.IOException;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.interactions.Actions;
- import org.testng.Assert;
- import org.testng.AssertJUnit;
- import org.testng.Reporter;
- import org.testng.annotations.AfterClass;
- import org.testng.annotations.BeforeClass;
- import org.testng.annotations.Test;
- public class APIWizardPage {
- public static WebDriver driver;
- GenericFunctions gfun = new GenericFunctions();
- public static String ConfigFilePath = "C:\\Users\\MaralayS\\workspace\\TestNG_selenium_suite\\config.properties";
- public static String POMFilePath = "C:\\Users\\MaralayS\\workspace\\TestNG_selenium_suite\\POMconfig.properties";
- String CurrentDir = System.getProperty("user.dir")+"";
- String Screenshot_Directory = CurrentDir+"\\Screenshot\\";
- @Test (priority=8)
- public void After_Login_Check() throws IOException
- {
- String Screenshot_Title = "AfterLoginTitleCheck.png";
- System.out.println("current Dir "+CurrentDir);
- Reporter.log("After Login to the Wizard");
- String PageTitle = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "LoginTitle");
- try
- {
- Assert.assertEquals(driver.getTitle().trim(), PageTitle);
- Reporter.log("After Login Page title Correct");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Title is not Same as expected , Or may be its not loaded completely within 10 sec, Please Check");
- }
- }
- @Test (priority=9)
- public void AfterLogin_VodafoneLogo() throws IOException
- {
- String Screenshot_Title = "AfterLoginLogoCheck.png";
- Reporter.log("After Login Logo Vodafone Circle Check");
- String LogoPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "LogoIcon");
- try
- {
- WebElement logo = driver.findElement(By.className(LogoPath));
- gfun.Highlight(logo,driver);
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("After Login Vodafone Logo Not Found");
- }
- }
- }
- @Test (priority=10)
- public void AfterLogin_API_Wizard_Text() throws IOException
- {
- String Screenshot_Title = "AfterLoginWizardTextCheck.png";
- Reporter.log("After Vodafone API Wizard Text Check");
- String WizardTextPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "APIWizardText");
- try
- {
- String WizardText = driver.findElements(By.xpath(WizardTextPath)).get(0).getText();
- AssertJUnit.assertEquals(WizardText,"Vodafone API Wizard");
- Reporter.log("After Login - Vodafone API Wizard Text Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- System.out.println("Exception "+e);
- try {
- AssertJUnit.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("After Login Vodafone API Wizard Text Not Found");
- }
- }
- }
- @Test (priority=11)
- public void AfterLogin_EmailLabel() throws IOException
- {
- String Screenshot_Title = "AfterLoginEmailLabel.png";
- Reporter.log("After Login Email Label Check");
- String EmailTitlepath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "EmailTitle");
- try
- {
- WebElement EmailTitle = driver.findElement(By.id(EmailTitlepath));
- gfun.Highlight(EmailTitle,driver);
- Thread.sleep(1000);
- Assert.assertEquals(true, true);
- Reporter.log("Email Label Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("After Login Email Title Not Found");
- }
- }
- }
- @Test (priority=12)
- public void AfterLogin_EmailId() throws IOException
- {
- String Screenshot_Title = "AfterLoginEmailId.png";
- Reporter.log("After Login Email ID Check");
- String username = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "username");
- String EmailIDPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "EmailID");
- try
- {
- WebElement EmailTitle = driver.findElement(By.id(EmailIDPath));
- gfun.Highlight(EmailTitle,driver);
- Thread.sleep(1000);
- Assert.assertEquals(username,EmailTitle.getText());
- Reporter.log("Email ID Found as used for login");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("After Login Email Title Not Found");
- }
- }
- }
- @Test (priority=13) //(timeOut=0,priority=1)
- public void APISpecification() throws IOException
- {
- String Screenshot_Title = "ApiSpecification.png";
- Reporter.log("ApiSpecification Check");
- String APISpecification = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ApiSpecification");
- try
- {
- WebElement EmailTitle = driver.findElement(By.xpath(APISpecification));
- gfun.Highlight(EmailTitle,driver);
- Thread.sleep(1000);
- Reporter.log("Api Specification Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("ApiSpecification Not Found");
- }
- }
- }
- @Test (priority=14) //(timeOut=0,priority=1)
- public void LoadEditor() throws IOException
- {
- String Screenshot_Title = "LoadEditor.png";
- Reporter.log("Load Editor Check");
- String LoadEditor = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Load");
- try
- {
- WebElement Load = driver.findElement(By.id(LoadEditor));
- gfun.Highlight(Load,driver);
- Thread.sleep(1000);
- Reporter.log("Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Load Editor Not Found");
- }
- }
- }
- @Test (priority=15) //Ignore //(timeOut=0,priority=1)
- public void SwaggerEditor() throws IOException
- {
- String Screenshot_Title = "SwaggerEditor.png";
- Reporter.log("SwaggerEditor Check");
- String SwaggerEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SwaggerEditor");
- try
- {
- WebElement SwaggerEditor= driver.findElement(By.id(SwaggerEditorPath));
- gfun.Highlight(SwaggerEditor,driver);
- Reporter.log("Swagger Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Swagger Editor Not Found");
- }
- }
- }
- @Test (priority=16) //(timeOut=0,priority=1)
- public void ValidateEditor() throws IOException
- {
- String Screenshot_Title = "ValidateEditor.png";
- Reporter.log("ValidateEditor Check");
- String ValidateEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ValidateEditor");
- try
- {
- WebElement ValidateEditor= driver.findElement(By.id(ValidateEditorPath));
- gfun.Highlight(ValidateEditor,driver);
- Reporter.log("Validate Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Validate Editor Not Found");
- }
- }
- }
- @Test (priority=17) //(timeOut=0,priority=1)
- public void ExportOAS_YAML() throws IOException
- {
- String Screenshot_Title = "ExportOAS_YAML.png";
- Reporter.log("Export OAS Yaml Check");
- String OutputEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_YAML");
- try
- {
- WebElement OutputEditor= driver.findElement(By.id(OutputEditorPath));
- gfun.Highlight(OutputEditor,driver);
- Reporter.log("Export OAS Yaml Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Export OAS Yaml Not Found");
- }
- }
- }
- @Test (priority=18) //(timeOut=0,priority=1)
- public void ExportOAS_JSON() throws IOException
- {
- String Screenshot_Title = "ExportOAS_JSON.png";
- Reporter.log("Export OAS JSON Check");
- String OutputEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_JSON");
- try
- {
- WebElement OutputEditor= driver.findElement(By.id(OutputEditorPath));
- gfun.Highlight(OutputEditor,driver);
- Reporter.log("Export OAS JSON Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Export OAS JSON Not Found");
- }
- }
- }
- @Test (priority=19) //(timeOut=0,priority=1)
- public void ReviewEditor() throws IOException
- {
- String Screenshot_Title = "ReviewEditor.png";
- Reporter.log("ReviewEditor Check");
- String ReviewEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ReviewEditor");
- try
- {
- WebElement ReviewEditor= driver.findElement(By.id(ReviewEditorPath));
- gfun.Highlight(ReviewEditor,driver);
- Reporter.log("Review Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Review Editor Not Found");
- }
- }
- }
- @Test (priority=20) //(timeOut=0,priority=1)
- public void Update_LoadEditor() throws IOException
- {
- String Screenshot_Title = "Update.png";
- Reporter.log("Update in Load Editor Check");
- String UpdatePath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Update");
- try
- {
- WebElement Update= driver.findElement(By.id(UpdatePath));
- gfun.Highlight(Update,driver);
- Reporter.log("Update in Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Update in load Editor Not Found");
- }
- }
- }
- @Test (priority=21) //(timeOut=0,priority=1)
- public void SampleSwagger_LoadEditor() throws IOException
- {
- String Screenshot_Title = "SampleSwagger.png";
- Reporter.log("SampleSwagger in Load Editor Check");
- String SampleSwaggerPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SampleSwagger");
- try
- {
- WebElement SampleSwagger= driver.findElement(By.xpath(SampleSwaggerPath));
- gfun.Highlight(SampleSwagger,driver);
- Reporter.log("Sample Swagger in Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Sample Swagger in load Editor Not Found");
- }
- }
- }
- @Test (priority=22) //(timeOut=0,priority=1)
- public void LoadSwagger_LoadEditor() throws IOException
- {
- String Screenshot_Title = "LoadSwagger.png";
- Reporter.log("LoadSwagger in Load Editor Check");
- String LoadSwaggerPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "LoadSwagger");
- try
- {
- WebElement LoadSwagger= driver.findElement(By.xpath(LoadSwaggerPath));
- gfun.Highlight(LoadSwagger,driver);
- Reporter.log("Load Swagger in Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Load Swagger in load Editor Not Found");
- }
- }
- }
- @Test (priority=23) //(timeOut=0,priority=1)
- public void SelectfileLabel_LoadEditor() throws IOException
- {
- String Screenshot_Title = "SelectFileLabel.png";
- Reporter.log("File Select Label in Load Editor Check");
- String FileSelectedLabelPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SelectFile");
- try
- {
- WebElement FileSelected= driver.findElement(By.xpath(FileSelectedLabelPath));
- gfun.Highlight(FileSelected,driver);
- Reporter.log("FileSelected: Label in Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("FileSelected: Label in load Editor Not Found");
- }
- }
- }
- @Test (priority=24) //(timeOut=0,priority=1)
- public void SelectfileValueInitial_LoadEditor() throws IOException
- {
- String Screenshot_Title = "SelectFileValueInitial.png";
- Reporter.log("SelectFileValue before select should be blank - Check");
- String FileSelectedPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "FileSelected");
- try
- {
- WebElement FileSelected= driver.findElement(By.id(FileSelectedPath));
- gfun.Highlight(FileSelected,driver);
- int length_beforefileselected = FileSelected.getText().length();
- Assert.assertEquals(length_beforefileselected, 0);
- Reporter.log("FileSelected: Value is blank in Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("FileSelected: Label in load Editor Not Found");
- }
- }
- }
- @Test (priority=25) //(timeOut=0,priority=1)
- public void Clear_LoadEditor() throws IOException
- {
- String Screenshot_Title = "Clear_loadEditor.png";
- Reporter.log("Clear in Load Editor - Check");
- String ClearPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Clear");
- try
- {
- WebElement Clear= driver.findElement(By.xpath(ClearPath));
- gfun.Highlight(Clear,driver);
- Reporter.log("Clear in Load Editor Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Clear in load Editor Not Found");
- }
- }
- }
- @Test (priority=26)
- public void Case1_UpdateTest() throws IOException
- {
- String Screenshot_Title = "Case1_UpdateTest.png";
- Reporter.log("Update the Swagger Test - Check");
- String UpdatePath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Update");
- String UpdateTextPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "UpdateText");
- try
- {
- WebElement LoadSwagger = driver.findElement(By.id(UpdatePath));
- LoadSwagger.click();
- Thread.sleep(500);
- WebElement AlertText = driver.findElement(By.id(UpdateTextPath));
- gfun.Highlight(AlertText, driver);
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- String alerttext = AlertText.getText();
- Assert.assertEquals(alerttext,"JSON definition parsed successfully");
- Thread.sleep(2000);
- Reporter.log("Update Alert popup Successfully");
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Update alert popup Not Found");
- }
- }
- }
- @Test (priority=27)
- public void Case2_SwaggerEditorCheck_Default() throws IOException, InterruptedException
- {
- String Screenshot_Title = "Case2_SwaggerEditorCheck_Default.png";
- Reporter.log(" SwaggerEditor Default - Check");
- String SwaggerEditorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SwaggerEditor");
- String SwaggerEditor_Left_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "SwaggerEditor_leftclass");
- try
- {
- WebElement SwaggerEditor = driver.findElement(By.id(SwaggerEditorPath));
- SwaggerEditor.click();
- Thread.sleep(5000);
- // Getting All the Div's//
- List<WebElement> DIVs= driver.findElements(By.tagName("div"));
- for(WebElement we : DIVs)
- {
- String classname = we.getAttribute("class");
- if((classname!=""||classname.length()>0) && (classname.equalsIgnoreCase("tab-pane")))
- {
- Thread.sleep(2000);
- try{
- driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
- }catch(Exception e)
- {
- Assert.assertEquals(1,1);
- System.out.println("Switching to iframe content");
- }
- Thread.sleep(1000);
- }
- }
- }
- catch(Exception e)
- {
- try {
- //Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case2 Swagger Editor Default Left and Right Container is not empty visibile - not Found");
- }
- }
- WebElement SE_Left = driver.findElement(By.className(SwaggerEditor_Left_Path));
- gfun.Highlight(SE_Left, driver);
- Thread.sleep(1000);
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- String left = SE_Left.getText();
- Assert.assertNotEquals(left.length(),0);
- driver.switchTo().defaultContent();
- Thread.sleep(2000);
- Reporter.log("Swagger Editor opened with proper contents - Successfully");
- }
- @Test (priority=28)
- public void Case3_SwaggerValidatorCheck_Default() throws IOException
- {
- String Screenshot_Title = "Case3_SwaggerValidatorCheck_Default.png";
- Reporter.log(" Swagger Validator Default - Check");
- String SwaggerValidatorPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ValidateEditor");
- String SwaggerValidatorClassPath = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ValidateEditorClass");
- try
- {
- WebElement SwaggerValidator = driver.findElement(By.id(SwaggerValidatorPath));
- SwaggerValidator.click();
- Thread.sleep(2000);
- WebElement SwaggerValidator_Class = driver.findElement(By.className(SwaggerValidatorClassPath));
- String Source = SwaggerValidator_Class.getText();
- Assert.assertNotEquals(Source,"ERROR");
- Assert.assertNotEquals(Source,"error");
- Reporter.log("Swagger Validator Default is visible with no error present - PASS");
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Swagger Validator Default is visible with error - FAIL");
- }
- }
- }
- @Test (priority=29)
- public void Case4_ExportOAM_YAML_Check_Default() throws IOException
- {
- String Screenshot_Title = "Case4_ExportOAM_YAML_Check_Default.png";
- Reporter.log("Case4_ExportOAM_YAML_Check_Default - Check");
- String ExportOAM_YAML_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_YAML");
- String ExportOAM_YAML_Class_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_YAML_id");
- String Alert1_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlert1");
- String Alert1_Button = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlertOKButton");
- try
- {
- Thread.sleep(5000);
- WebElement ExportOAMPATH = driver.findElement(By.id(ExportOAM_YAML_Path));
- ExportOAMPATH.click();
- Thread.sleep(2000);
- WebElement ExportOAMPATH_Class = driver.findElement(By.id(ExportOAM_YAML_Class_Path));
- String Source = ExportOAMPATH_Class.getText();
- if(Source.contains("swagger"))
- {
- Assert.assertEquals(true,true);
- Reporter.log("Export OAS Yaml file contents are visible and non Empty");
- }
- else
- {
- Assert.assertEquals(false,true);
- Reporter.log("Export OAS Yaml file contents is not visble or is Empty");
- }
- try
- {
- WebElement alert1 = driver.findElement(By.id(Alert1_Path));
- WebElement alert1button = driver.findElement(By.id(Alert1_Button));
- alert1button.click();
- Assert.assertEquals(false, true);
- Reporter.log("For Valid Swagger - Alert is coming [Update Swagger is not in the proper format] - FAIL");
- }
- catch(Exception e)
- {
- Reporter.log("For Valid Swagger , Alert [Update Swagger is not in the proper format] is not present");
- Assert.assertEquals(true,true);
- }
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case4 Export OAS Yaml Default is visible with contents - shown Successfully");
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case4 Export OAS Yaml Default is not visible ");
- }
- }
- }
- @Test (priority=30)
- public void Case5_ExportOAM_JSON_Check_Default() throws IOException
- {
- String Screenshot_Title = "Case5_ExportOAM_JSON_Check_Default.png";
- Reporter.log("Case5_ExportOAM_JSON_Check_Default - Check");
- String ExportOAM_JSON_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_JSON");
- String ExportOAM_JSON_Class_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ExportOAS_JSON_id");
- String Alert1_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlert1");
- String Alert1_Button = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "CheckAlertOKButton");
- try
- {
- Thread.sleep(5000);
- WebElement ExportOAMPATH = driver.findElement(By.id(ExportOAM_JSON_Path));
- ExportOAMPATH.click();
- Thread.sleep(2000);
- WebElement ExportOAMPATH_Class = driver.findElement(By.id(ExportOAM_JSON_Class_Path));
- String Source = ExportOAMPATH_Class.getText();
- if(Source.contains("swagger"))
- {
- Assert.assertEquals(true,true);
- Reporter.log("Export OAS JSON file contents are visible and non Empty");
- }
- else
- {
- Assert.assertEquals(false,true);
- Reporter.log("Export OAS JSON file contents is not visble or is Empty");
- }
- try
- {
- WebElement alert1 = driver.findElement(By.id(Alert1_Path));
- WebElement alert1button = driver.findElement(By.id(Alert1_Button));
- alert1button.click();
- Reporter.log("For Valid Swagger OAS JSON, Alert [Update Swagger is not in the proper format] should not present");
- Assert.assertEquals(false,true);
- }
- catch(Exception e)
- {
- Reporter.log("For Valid Swagger OAS JSON, Alert [Update Swagger is not in the proper format] should not present");
- Assert.assertEquals(true,true);
- }
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case5 Export OAS JSON Default is visible with contents - shown Successfully");
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case5 Export OAS Yaml Default is not visible ");
- }
- }
- }
- @Test (priority=31)
- public void Case6_Review_Check_Default() throws IOException
- {
- String Screenshot_Title = "Case6_Review_Check_Default.png";
- Reporter.log("Case6_Review_Check_Default - Check");
- String ReviewEditor_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "ReviewEditor");
- String Submit_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Submit");
- try
- {
- Thread.sleep(5000);
- WebElement ReviewPATH = driver.findElement(By.id(ReviewEditor_Path));
- ReviewPATH.click();
- Thread.sleep(2000);
- try
- {
- WebElement Submit = driver.findElement(By.id(Submit_Path));
- Reporter.log("Review Container - Submit present");
- gfun.Highlight(Submit, driver);
- Assert.assertEquals(true,true);
- }
- catch(Exception e)
- {
- Reporter.log("Review Container - Submit not present");
- Assert.assertEquals(false,true);
- }
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case6 Review with submit button for Default case - shown Successfully");
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Case6 Review with submit button is not visible ");
- }
- }
- }
- @Test (priority=32)
- public void Logout() throws IOException
- {
- String Screenshot_Title = "logout.png";
- Reporter.log("Logout Check");
- String Logout_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Logout");
- try
- {
- WebElement Logout = driver.findElement(By.id(Logout_Path));
- Actions actions = new Actions(driver);
- gfun.Highlight(Logout,driver);
- Reporter.log("Logout Found");
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- actions.moveToElement(Logout);
- actions.click();
- actions.build().perform();
- }
- catch(Exception e)
- {
- try {
- Assert.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- GenericFunctions.TakeScreenshot(driver, new File(Screenshot_Directory+Screenshot_Title));
- Reporter.log("Logout Not Found");
- }
- }
- }
- @BeforeClass
- public void BeforeClass() throws IOException
- {
- driver = gfun.InitiateDriver(new File(ConfigFilePath));
- String URL = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "BaseURL");
- String Timeout = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "TimeOut");
- int time = Integer.parseInt(Timeout);
- driver.get(URL);
- driver.manage().timeouts().implicitlyWait(time,TimeUnit.SECONDS);
- String Title = driver.getTitle();
- if(Title.contains("4")||Title.contains("503")||Title.length()<=0)
- {
- Reporter.log("Page is not opening , Some issue with the URL or Internet Connectivity slowness , Server not respond. Kindly Check and retry");
- System.out.println("Page is not responding"+driver.getTitle());
- AssertJUnit.assertEquals(driver.getTitle(), "Vodafone API Wizard");
- }
- /**
- * Login Again
- */
- String username = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "username");
- String password = GenericFunctions.ReadPropertyFile(new File(ConfigFilePath), "password");
- String Email_ID_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Email_Id_TextBox");
- String Password_ID_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Password_TextBox");
- String Login_Button = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "LoginButton");
- String Logout_Path = GenericFunctions.ReadPropertyFile(new File(POMFilePath), "Logout");
- try
- {
- Actions actions = new Actions(driver);
- Thread.sleep(5000);
- WebElement EmailID = driver.findElement(By.id(Email_ID_Path));
- EmailID.sendKeys(username);
- WebElement Password = driver.findElement(By.id(Password_ID_Path));
- Password.sendKeys(password);
- WebElement LoginButton = driver.findElement(By.xpath(Login_Button));
- actions.moveToElement(LoginButton);
- actions.click();
- actions.build().perform();
- Thread.sleep(2000);
- driver.navigate().to(URL);
- Thread.sleep(5000);
- }
- catch(Exception e)
- {
- System.out.println("Exception "+e);
- try {
- AssertJUnit.assertEquals(true, false);
- }
- catch(Exception e1)
- {
- Reporter.log("Login Unsuccessfull, Please check user is registered or not");
- }
- }
- }
- @AfterClass
- public void CloseBrowser() throws IOException
- {
- driver.close();
- driver.quit();
- }
- }
Add Comment
Please, Sign In to add comment