diff --git a/allAutomation/.idea/workspace.xml b/allAutomation/.idea/workspace.xml index f3f45741..6d2f3684 100644 --- a/allAutomation/.idea/workspace.xml +++ b/allAutomation/.idea/workspace.xml @@ -5,7 +5,14 @@ + + + + + + + diff --git a/allAutomation/src/main/java/Pages/output_audio.wav.wav b/allAutomation/src/main/java/Pages/output_audio.wav.wav index dfb0aefc..15337efa 100644 Binary files a/allAutomation/src/main/java/Pages/output_audio.wav.wav and b/allAutomation/src/main/java/Pages/output_audio.wav.wav differ diff --git a/allAutomation/src/main/java/Tests/AllTest.java b/allAutomation/src/main/java/Tests/AllTest.java index 64f599a7..c4e692a9 100644 --- a/allAutomation/src/main/java/Tests/AllTest.java +++ b/allAutomation/src/main/java/Tests/AllTest.java @@ -28,225 +28,6 @@ public AllTest() { System.out.println("AllTest constructor called."); } -// @Test -// public void Login() throws Exception { -// System.out.println("Login test started."); -// -// try { -// browserRun(); -// LoginPage lp = PageFactory.initElements(BaseUtils.driver, LoginPage.class); -// -// logStep("Enter username"); -// driver.findElement(By.id(":r0:")).sendKeys("Amol"); -// -// waitForUi(2); -// logStep("Enter password"); -// driver.findElement(By.id(":r1:")).sendKeys("Amol@123"); -// -// logStep("Click on Submit Button"); -// driver.findElement(By.xpath("//button[@type='submit']")).click(); -// -// waitForUi(2); -// Thread.sleep(3000); -// -// logStep("Click on Mike button"); -// driver.findElement(By.xpath("//div[@class='MuiBox-root css-14j5rrt']")).click(); -// -// Thread.sleep(3000); -// -// logStep("Get Text from UI"); -// String text = driver.findElement(By.xpath("//h4[@class='MuiTypography-root MuiTypography-h5 css-xilszg']")).getText(); -// System.out.println("Extracted text: " + text); -// -// Thread.sleep(3000); -// -// driver.findElement(By.className("game-action-button")).click(); -// -// // Create a voice manager -// VoiceManager voiceManager = VoiceManager.getInstance(); -// -// // Select the voice -// Voice voice = voiceManager.getVoice("kevin16"); -// if (voice == null) { -// System.err.println("Cannot find a voice named kevin16.\nPlease specify a different voice."); -// System.exit(1); -// } -// -// // Allocate the chosen voice -// voice.allocate(); -// -// // Ensure the directory exists -// String directoryPath = "src/main/java/Pages"; // Adjust this path as needed -// String fileName = "output_audio"; // Adjust the file name as needed -// String outputPath = directoryPath + "/" + fileName + ".wav"; -// -// // Create directory if it doesn't exist -// File directory = new File(directoryPath); -// if (!directory.exists()) { -// directory.mkdirs(); -// } -// -// // Create a SingleFileAudioPlayer -// SingleFileAudioPlayer audioPlayer = new SingleFileAudioPlayer(outputPath, javax.sound.sampled.AudioFileFormat.Type.WAVE); -// voice.setAudioPlayer(audioPlayer); -// -// voice.speak(text); -// -// audioPlayer.close(); -// // Deallocate the voice resources -// voice.deallocate(); -// -// System.out.println("Audio file created successfully at: " + outputPath); -// -// // Convert audio file to Base64 -// String base64Audio = convertWavToBase64(outputPath); -// System.out.println("Base64 Audio: " + base64Audio); -// -// // Save Base64 string to a file -// String base64FilePath = directoryPath + "/Base64Audio.txt"; -// saveBase64ToFile(base64FilePath, base64Audio); -// System.out.println("Base64 Audio saved successfully at: " + base64FilePath); -// -// Thread.sleep(4000); -// // Example click action -// // driver.findElement(By.xpath("//button[text()='Example']")).click(); -// } catch (Exception e) { -// e.printStackTrace(); -// throw e; -// } -// -// System.out.println("Login test completed."); -// } - -// public static void logStep(String message) { -// System.out.println(message); -// } - - - /* @Test - public void Login() throws Exception { - System.out.println("Login test started."); - - try { - browserRun(); - LoginPage lp = PageFactory.initElements(BaseUtils.driver, LoginPage.class); - - logStep("Enter username"); - driver.findElement(By.id(":r0:")).sendKeys("Amol"); - - waitForUi(2); - logStep("Enter password"); - driver.findElement(By.id(":r1:")).sendKeys("Amol@123"); - - logStep("Click on Submit Button"); - driver.findElement(By.xpath("//button[@type='submit']")).click(); - - waitForUi(2); - Thread.sleep(3000); - - logStep("Click on Mike button"); - driver.findElement(By.xpath("//div[@class='MuiBox-root css-14j5rrt']")).click(); - - Thread.sleep(3000); - - logStep("Get Text from UI"); - String text = driver.findElement(By.xpath("//h4[@class='MuiTypography-root MuiTypography-h5 css-xilszg']")).getText(); - System.out.println("Extracted text: " + text); - - Thread.sleep(3000); - - // Save audio file - saveTextToAudio(text); - - // Click on game action button - logStep("Click on Game Action Button"); - driver.findElement(By.className("game-action-button")).click(); - - Thread.sleep(4000); - driver.findElement(By.xpath("(//*[@xmlns='http://www.w3.org/2000/svg'])[2]")).click(); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - System.out.println("Login test completed."); - } - - private void saveTextToAudio(String text) { - try { - System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); - - // Create a voice manager - VoiceManager voiceManager = VoiceManager.getInstance(); - - // Select the voice - Voice voice = voiceManager.getVoice("kevin16"); - if (voice == null) { - System.err.println("Cannot find a voice named kevin16.\n" + - "Please specify a different voice."); - System.exit(1); - } - - // Allocate the chosen voice - voice.allocate(); - - // Ensure the directory exists - String directoryPath = "src/main/java/Pages"; // Adjust this path as needed - String fileName = "output_audio"; // Adjust the file name as needed - String outputPath = directoryPath + "/" + fileName + ".wav"; - - // Create directory if it doesn't exist - File directory = new File(directoryPath); - if (!directory.exists()) { - directory.mkdirs(); - } - - // Create a SingleFileAudioPlayer - SingleFileAudioPlayer audioPlayer = new SingleFileAudioPlayer(outputPath, javax.sound.sampled.AudioFileFormat.Type.WAVE); - voice.setAudioPlayer(audioPlayer); - - voice.speak(text); - - audioPlayer.close(); - // Deallocate the voice resources - voice.deallocate(); - - System.out.println("Audio file created successfully at: " + outputPath); - - // Convert audio file to Base64 - String base64Audio = convertWavToBase64(outputPath); - System.out.println("Base64 Audio: " + base64Audio); - - // Save Base64 string to a file - String base64FilePath = directoryPath + "/Base64Audio.txt"; - saveBase64ToFile(base64FilePath, base64Audio); - System.out.println("Base64 Audio saved successfully at: " + base64FilePath); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static String convertWavToBase64(String filePath) { - String base64String = ""; - try { - byte[] bytes = Files.readAllBytes(Paths.get(filePath)); - base64String = Base64.getEncoder().encodeToString(bytes); - } catch (IOException e) { - e.printStackTrace(); - } - return base64String; - } - - private static void saveBase64ToFile(String filePath, String base64String) { - try (FileWriter fileWriter = new FileWriter(filePath)) { - fileWriter.write(base64String); - } catch (IOException e) { - e.printStackTrace(); - } - }*/ - - - @@ -291,38 +72,37 @@ public static void Login() throws Exception { logStep(Text); -// System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); - - - - AudioFormat[] formatsToTry = { - new AudioFormat(44100.0f, 16, 2, true, false), // PCM_SIGNED 44100 Hz, 16 bit, stereo, little-endian - new AudioFormat(16000.0f, 16, 1, true, true) // PCM_SIGNED 16000 Hz, 16 bit, mono, big-endian - }; - - for (AudioFormat format : formatsToTry) { - DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); - if (AudioSystem.isLineSupported(info)) { - try (SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info)) { - line.open(format); - line.start(); - // Your audio processing code here - line.drain(); - System.out.println("Using format: " + format); - break; // Exit loop if a supported format is found - } catch (Exception e) { - e.printStackTrace(); - } - } else { - System.out.println("Format " + format + " is not supported."); - } - } + TexttoSpeach(Text); + Thread.sleep(4000); + driver.findElement(By.xpath("(//*[@xmlns='http://www.w3.org/2000/svg'])[2]")).click(); + } + private static String convertWavToBase64(String filePath) { + String base64String = ""; + try { + File file = new File(filePath); + byte[] bytes = Files.readAllBytes(file.toPath()); + base64String = Base64.getEncoder().encodeToString(bytes); + } catch (IOException e) { + e.printStackTrace(); + } + return base64String; + } + + private static void saveBase64ToFile(String filePath, String base64String) { + try (FileWriter fileWriter = new FileWriter(filePath)) { + fileWriter.write(base64String); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void TexttoSpeach(String Text) throws InterruptedException { System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); logStep("Speak text in Mike"); @@ -376,37 +156,14 @@ public static void Login() throws Exception { String base64FilePath = directoryPath + "/Base64Audio.txt"; saveBase64ToFile(base64FilePath, base64Audio); System.out.println("Base64 Audio saved successfully at: " + base64FilePath); - -// driver.findElement(By.xpath("//*[@fill='url(#paint0_linear_400_1340)']")).sendKeys("https://all-dev-content-service.s3.ap-south-1.amazonaws.com/all-audio-files/en/44983c9c-48d4-4605-8e03-f7ae3932ad3e.wav"); - Thread.sleep(4000); - driver.findElement(By.xpath("(//*[@xmlns='http://www.w3.org/2000/svg'])[2]")).click(); - - String audioFilePath = "output.mp3"; -// convertTextToSpeech(Text,audioFilePath); - } - private static String convertWavToBase64(String filePath) { - String base64String = ""; - try { - File file = new File(filePath); - byte[] bytes = Files.readAllBytes(file.toPath()); - base64String = Base64.getEncoder().encodeToString(bytes); - } catch (IOException e) { - e.printStackTrace(); - } - return base64String; - } - private static void saveBase64ToFile(String filePath, String base64String) { - try (FileWriter fileWriter = new FileWriter(filePath)) { - fileWriter.write(base64String); - } catch (IOException e) { - e.printStackTrace(); - } - } +} -} +// +// String audioFilePath = "output.mp3"; +//// convertTextToSpeech(Text,audioFilePath); \ No newline at end of file diff --git a/allAutomation/src/main/java/Tests/LoginTest.java b/allAutomation/src/main/java/Tests/LoginTest.java index 01ccfac4..2c228410 100644 --- a/allAutomation/src/main/java/Tests/LoginTest.java +++ b/allAutomation/src/main/java/Tests/LoginTest.java @@ -40,3 +40,224 @@ public static void Login() throws Exception { } } + + + +//@Test +// public void Login() throws Exception { +// System.out.println("Login test started."); +// +// try { +// browserRun(); +// LoginPage lp = PageFactory.initElements(BaseUtils.driver, LoginPage.class); +// +// logStep("Enter username"); +// driver.findElement(By.id(":r0:")).sendKeys("Amol"); +// +// waitForUi(2); +// logStep("Enter password"); +// driver.findElement(By.id(":r1:")).sendKeys("Amol@123"); +// +// logStep("Click on Submit Button"); +// driver.findElement(By.xpath("//button[@type='submit']")).click(); +// +// waitForUi(2); +// Thread.sleep(3000); +// +// logStep("Click on Mike button"); +// driver.findElement(By.xpath("//div[@class='MuiBox-root css-14j5rrt']")).click(); +// +// Thread.sleep(3000); +// +// logStep("Get Text from UI"); +// String text = driver.findElement(By.xpath("//h4[@class='MuiTypography-root MuiTypography-h5 css-xilszg']")).getText(); +// System.out.println("Extracted text: " + text); +// +// Thread.sleep(3000); +// +// driver.findElement(By.className("game-action-button")).click(); +// +// // Create a voice manager +// VoiceManager voiceManager = VoiceManager.getInstance(); +// +// // Select the voice +// Voice voice = voiceManager.getVoice("kevin16"); +// if (voice == null) { +// System.err.println("Cannot find a voice named kevin16.\nPlease specify a different voice."); +// System.exit(1); +// } +// +// // Allocate the chosen voice +// voice.allocate(); +// +// // Ensure the directory exists +// String directoryPath = "src/main/java/Pages"; // Adjust this path as needed +// String fileName = "output_audio"; // Adjust the file name as needed +// String outputPath = directoryPath + "/" + fileName + ".wav"; +// +// // Create directory if it doesn't exist +// File directory = new File(directoryPath); +// if (!directory.exists()) { +// directory.mkdirs(); +// } +// +// // Create a SingleFileAudioPlayer +// SingleFileAudioPlayer audioPlayer = new SingleFileAudioPlayer(outputPath, javax.sound.sampled.AudioFileFormat.Type.WAVE); +// voice.setAudioPlayer(audioPlayer); +// +// voice.speak(text); +// +// audioPlayer.close(); +// // Deallocate the voice resources +// voice.deallocate(); +// +// System.out.println("Audio file created successfully at: " + outputPath); +// +// // Convert audio file to Base64 +// String base64Audio = convertWavToBase64(outputPath); +// System.out.println("Base64 Audio: " + base64Audio); +// +// // Save Base64 string to a file +// String base64FilePath = directoryPath + "/Base64Audio.txt"; +// saveBase64ToFile(base64FilePath, base64Audio); +// System.out.println("Base64 Audio saved successfully at: " + base64FilePath); +// +// Thread.sleep(4000); +// // Example click action +// // driver.findElement(By.xpath("//button[text()='Example']")).click(); +// } catch (Exception e) { +// e.printStackTrace(); +// throw e; +// } +// +// System.out.println("Login test completed."); +// } + +// public static void logStep(String message) { +// System.out.println(message); +// } + + + /* @Test + public void Login() throws Exception { + System.out.println("Login test started."); + + try { + browserRun(); + LoginPage lp = PageFactory.initElements(BaseUtils.driver, LoginPage.class); + + logStep("Enter username"); + driver.findElement(By.id(":r0:")).sendKeys("Amol"); + + waitForUi(2); + logStep("Enter password"); + driver.findElement(By.id(":r1:")).sendKeys("Amol@123"); + + logStep("Click on Submit Button"); + driver.findElement(By.xpath("//button[@type='submit']")).click(); + + waitForUi(2); + Thread.sleep(3000); + + logStep("Click on Mike button"); + driver.findElement(By.xpath("//div[@class='MuiBox-root css-14j5rrt']")).click(); + + Thread.sleep(3000); + + logStep("Get Text from UI"); + String text = driver.findElement(By.xpath("//h4[@class='MuiTypography-root MuiTypography-h5 css-xilszg']")).getText(); + System.out.println("Extracted text: " + text); + + Thread.sleep(3000); + + // Save audio file + saveTextToAudio(text); + + // Click on game action button + logStep("Click on Game Action Button"); + driver.findElement(By.className("game-action-button")).click(); + + Thread.sleep(4000); + driver.findElement(By.xpath("(//*[@xmlns='http://www.w3.org/2000/svg'])[2]")).click(); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + System.out.println("Login test completed."); + } + + private void saveTextToAudio(String text) { + try { + System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"); + + // Create a voice manager + VoiceManager voiceManager = VoiceManager.getInstance(); + + // Select the voice + Voice voice = voiceManager.getVoice("kevin16"); + if (voice == null) { + System.err.println("Cannot find a voice named kevin16.\n" + + "Please specify a different voice."); + System.exit(1); + } + + // Allocate the chosen voice + voice.allocate(); + + // Ensure the directory exists + String directoryPath = "src/main/java/Pages"; // Adjust this path as needed + String fileName = "output_audio"; // Adjust the file name as needed + String outputPath = directoryPath + "/" + fileName + ".wav"; + + // Create directory if it doesn't exist + File directory = new File(directoryPath); + if (!directory.exists()) { + directory.mkdirs(); + } + + // Create a SingleFileAudioPlayer + SingleFileAudioPlayer audioPlayer = new SingleFileAudioPlayer(outputPath, javax.sound.sampled.AudioFileFormat.Type.WAVE); + voice.setAudioPlayer(audioPlayer); + + voice.speak(text); + + audioPlayer.close(); + // Deallocate the voice resources + voice.deallocate(); + + System.out.println("Audio file created successfully at: " + outputPath); + + // Convert audio file to Base64 + String base64Audio = convertWavToBase64(outputPath); + System.out.println("Base64 Audio: " + base64Audio); + + // Save Base64 string to a file + String base64FilePath = directoryPath + "/Base64Audio.txt"; + saveBase64ToFile(base64FilePath, base64Audio); + System.out.println("Base64 Audio saved successfully at: " + base64FilePath); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static String convertWavToBase64(String filePath) { + String base64String = ""; + try { + byte[] bytes = Files.readAllBytes(Paths.get(filePath)); + base64String = Base64.getEncoder().encodeToString(bytes); + } catch (IOException e) { + e.printStackTrace(); + } + return base64String; + } + + private static void saveBase64ToFile(String filePath, String base64String) { + try (FileWriter fileWriter = new FileWriter(filePath)) { + fileWriter.write(base64String); + } catch (IOException e) { + e.printStackTrace(); + } + }*/ + + diff --git a/allAutomation/src/main/java/utils/baseutils/BrowserManager.java b/allAutomation/src/main/java/utils/baseutils/BrowserManager.java index f8d753e0..124e5829 100644 --- a/allAutomation/src/main/java/utils/baseutils/BrowserManager.java +++ b/allAutomation/src/main/java/utils/baseutils/BrowserManager.java @@ -19,83 +19,84 @@ import java.util.Properties; -/*public class BrowserManager extends BaseUtils { - static String locatorsPath = System.getProperty("user.dir") + "/src/test/java/test/resources/locators/"; - static { - PropertiesFileManager.getInstance().setPath(locatorsPath); - } - - private static String environment; - static String envFilePath = "src/test/ENV.properties"; - public static void readEnvironment(String envFilePath) { - try { - byte[] encoded = Files.readAllBytes(Paths.get(envFilePath)); - environment = new String(encoded).trim(); - } catch (IOException e) { - System.out.println("Error reading the file: " + e.getMessage()); - System.out.println("Error reading the file: " + e.getMessage()); - - } - } - - - public static void browserRun() throws Exception { - - FileReader fr = new FileReader(System.getProperty("user.dir") + "/src/test/java/test/resources/Test_data/browserConfig.properties"); - Properties prop = new Properties(); - prop.load(fr); - - if (prop.getProperty("Browser").equalsIgnoreCase("chrome")) { - - ChromeOptions opt = new ChromeOptions(); - //opt.setHeadless(true); - opt.addArguments("--remote-allow-origins=*"); - opt.addArguments("--incognito"); - opt.addArguments("--use-fake-ui-for-media-stream"); - -// opt.setBrowserVersion("116"); - - driver = new ChromeDriver(opt); - - } else if (prop.getProperty("Browser").equalsIgnoreCase("firefox")) { +//public class BrowserManager extends BaseUtils { +// static String locatorsPath = System.getProperty("user.dir") + "/src/test/java/test/resources/locators/"; +// static { +// PropertiesFileManager.getInstance().setPath(locatorsPath); +// } +// +// private static String environment; +// static String envFilePath = "src/test/ENV.properties"; +// public static void readEnvironment(String envFilePath) { +// try { +// byte[] encoded = Files.readAllBytes(Paths.get(envFilePath)); +// environment = new String(encoded).trim(); +// } catch (IOException e) { +// System.out.println("Error reading the file: " + e.getMessage()); +// System.out.println("Error reading the file: " + e.getMessage()); +// +// } +// } +// +// +// public static void browserRun() throws Exception { +// +// FileReader fr = new FileReader(System.getProperty("user.dir") + "/src/test/java/test/resources/Test_data/browserConfig.properties"); +// Properties prop = new Properties(); +// prop.load(fr); +// +// if (prop.getProperty("Browser").equalsIgnoreCase("chrome")) { +// +// ChromeOptions opt = new ChromeOptions(); +// //opt.setHeadless(true); +// opt.addArguments("--remote-allow-origins=*"); +// opt.addArguments("--incognito"); +// opt.addArguments("--use-fake-ui-for-media-stream"); +// +//// opt.setBrowserVersion("116"); +// +// driver = new ChromeDriver(opt); +// +// } else if (prop.getProperty("Browser").equalsIgnoreCase("firefox")) { +// +// FirefoxOptions opt = new FirefoxOptions(); +// +// opt.setBinary("/usr/bin/firefox"); +// +// driver = new FirefoxDriver(opt); +// +// +// } else if (prop.getProperty("Browser").equalsIgnoreCase("edge")) { +// +// EdgeOptions opt = new EdgeOptions(); +// +// opt.addArguments("--remote-allow-origins=*"); +// driver = new EdgeDriver(); +// +// } else { +// +// System.out.println("Invalid Browser Selection"); +// +// } +// +// driver.manage().window().maximize(); +// +// readEnvironment(envFilePath); +// switch (environment) +// { +// case "QA" : driver.get("https://d114esnbvw5tst.cloudfront.net/"); +// case "DEV" : driver.get("https://d114esnbvw5tst.cloudfront.net/"); +//// case "PROD" : driver.get(prop.getProperty("PROD_URL")); +// +// } +// +// } +// +// public static void main(String[] args) throws Exception { +// browserRun(); +// } +//} - FirefoxOptions opt = new FirefoxOptions(); - - opt.setBinary("/usr/bin/firefox"); - - driver = new FirefoxDriver(opt); - - - } else if (prop.getProperty("Browser").equalsIgnoreCase("edge")) { - - EdgeOptions opt = new EdgeOptions(); - - opt.addArguments("--remote-allow-origins=*"); - driver = new EdgeDriver(); - - } else { - - System.out.println("Invalid Browser Selection"); - - } - - driver.manage().window().maximize(); - - readEnvironment(envFilePath); - switch (environment) - { - case "QA" : driver.get("https://d114esnbvw5tst.cloudfront.net/"); - case "DEV" : driver.get("https://d114esnbvw5tst.cloudfront.net/"); -// case "PROD" : driver.get(prop.getProperty("PROD_URL")); - - } - - } - - public static void main(String[] args) throws Exception { - browserRun(); - } -}*/ diff --git a/allAutomation/target/classes/Tests/AllTest.class b/allAutomation/target/classes/Tests/AllTest.class index e9aec66b..77bb8e05 100644 Binary files a/allAutomation/target/classes/Tests/AllTest.class and b/allAutomation/target/classes/Tests/AllTest.class differ diff --git a/allAutomation/target/classes/utils/baseutils/BrowserManager.class b/allAutomation/target/classes/utils/baseutils/BrowserManager.class index ed06ef32..ceca0437 100644 Binary files a/allAutomation/target/classes/utils/baseutils/BrowserManager.class and b/allAutomation/target/classes/utils/baseutils/BrowserManager.class differ