Skip to content

Commit

Permalink
all_Automation_Git_Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
AmolKadam-Tekdi committed Jul 8, 2024
1 parent 7e731d2 commit d31f1cb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 59 deletions.
7 changes: 1 addition & 6 deletions allAutomation/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 63 additions & 53 deletions allAutomation/src/main/java/Tests/AllTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,84 +20,94 @@ public class AllTest extends BrowserManager {

public AllTest() {
// No-argument constructor
System.out.println("AllTest constructor called.");
}

@Test
public void Login() throws Exception {
browserRun();
LoginPage lp = PageFactory.initElements(BaseUtils.driver, LoginPage.class);
System.out.println("Login test started.");

logStep("Enter username");
driver.findElement(By.id(":r0:")).sendKeys("Amol");
try {
browserRun();
LoginPage lp = PageFactory.initElements(BaseUtils.driver, LoginPage.class);

waitForUi(2);
logStep("Enter password");
driver.findElement(By.id(":r1:")).sendKeys("Amol@123");
logStep("Enter username");
driver.findElement(By.id(":r0:")).sendKeys("Amol");

driver.findElement(By.xpath("//button[@type='submit']")).click();
waitForUi(2);
logStep("Enter password");
driver.findElement(By.id(":r1:")).sendKeys("Amol@123");

waitForUi(2);
Thread.sleep(3000);
driver.findElement(By.xpath("//button[@type='submit']")).click();

driver.findElement(By.xpath("//div[@class='MuiBox-root css-14j5rrt']")).click();
waitForUi(2);
Thread.sleep(3000);

Thread.sleep(3000);
driver.findElement(By.xpath("//div[@class='MuiBox-root css-14j5rrt']")).click();

String text = driver.findElement(By.xpath("//h4[@class='MuiTypography-root MuiTypography-h5 css-xilszg']")).getText();
System.out.println(text);
Thread.sleep(3000);

driver.findElement(By.className("game-action-button")).click();
String text = driver.findElement(By.xpath("//h4[@class='MuiTypography-root MuiTypography-h5 css-xilszg']")).getText();
System.out.println("Extracted text: " + text);

System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
driver.findElement(By.className("game-action-button")).click();

// Create a voice manager
VoiceManager voiceManager = VoiceManager.getInstance();
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");

// 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);
}
// Create a voice manager
VoiceManager voiceManager = VoiceManager.getInstance();

// Allocate the chosen voice
voice.allocate();
// 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);
}

// 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";
// Allocate the chosen voice
voice.allocate();

// Create directory if it doesn't exist
File directory = new File(directoryPath);
if (!directory.exists()) {
directory.mkdirs();
}
// 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);
// Create a SingleFileAudioPlayer
SingleFileAudioPlayer audioPlayer = new SingleFileAudioPlayer(outputPath, javax.sound.sampled.AudioFileFormat.Type.WAVE);
voice.setAudioPlayer(audioPlayer);

voice.speak(text);
voice.speak(text);

audioPlayer.close();
// Deallocate the voice resources
voice.deallocate();
audioPlayer.close();
// Deallocate the voice resources
voice.deallocate();

System.out.println("Audio file created successfully at: " + outputPath);
System.out.println("Audio file created successfully at: " + outputPath);

// Convert audio file to Base64
String base64Audio = convertWavToBase64(outputPath);
System.out.println("Base64 Audio: " + base64Audio);
// 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);
// 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);
driver.findElement(By.xpath("(//*[@xmlns='http://www.w3.org/2000/svg'])[2]")).click();
} catch (Exception e) {
e.printStackTrace();
throw e;
}

Thread.sleep(4000);
driver.findElement(By.xpath("(//*[@xmlns='http://www.w3.org/2000/svg'])[2]")).click();
System.out.println("Login test completed.");
}

public static void logStep(String message) {
Expand Down

0 comments on commit d31f1cb

Please sign in to comment.