Code sample as below:
File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File(“snapshot.png”));
Azure, RPA, AI, Selenium, Angular, API
File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File(“snapshot.png”));
String Xport = System.getProperty(“lmportal.xvfb.id”, “:1”); // setup firefox binary to start Xvfb
final File ffPath = new File(System.getProperty(“lmportal.deploy.firefox.path”, “/usr/bin/firefox”));
FirefoxBinary ffBinary = new FirefoxBinary(ffPath);
ffBinary.setEnvironmentProperty(“DISPLAY”, Xport);
WebDriver driver = new FirefoxDriver(ffBinary, null);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(“URL”);
For Chrome, add –ignore-certificate-errors in following code
options = webdriver.ChromeOptions()
options.add_argument(‘–ignore-certificate-errors’)
driver = webdriver.Chrome(chrome_options=options)
driver.get(‘URL’)
For the Internet Explorer, set acceptSslCerts desired capability as true:
capabilities = webdriver.DesiredCapabilities().INTERNETEXPLORER
capabilities[‘acceptSslCerts’] = True
driver = webdriver.Ie(capabilities=capabilities)
driver.get(‘URL’)
For Firefox, set accept_untrusted_certs as true
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
driver = webdriver.Firefox(firefox_profile=profile)
driver.get(‘URL’)
https://www.youtube.com/watch?v=8G27oLuUTVA
class ForLoop {
public static void main(String[] args) {
int c;
for (c = 1; c <= 10; c++) {
System.out.println(c);
}
}
}
import java.util.Scanner;
class IfElse {
public static void main(String[] args) {
int marksObtained, passingMarks;
passingMarks = 40;
Scanner input = new Scanner(System.in);
System.out.println(“Input marks scored by you”);
marksObtained = input.nextInt();
if (marksObtained >= passingMarks) {
System.out.println(“You passed the exam.”);
}
else {
System.out.println(“Unfortunately you failed to pass the exam.”);
}
}
}
import java.util.Scanner;
class NestedIfElse {
public static void main(String[] args) {
int marksObtained, passingMarks;
char grade;
passingMarks = 40;
Scanner input = new Scanner(System.in);
System.out.println(“Input marks scored by you”);
marksObtained = input.nextInt();
if (marksObtained >= passingMarks) {
if (marksObtained > 90)
grade = ‘A’;
else if (marksObtained > 75)
grade = ‘B’;
else if (marksObtained > 60)
grade = ‘C’;
else
grade = ‘D’;
System.out.println(“You passed the exam and your grade is ” + grade);
}
else {
grade = ‘F’;
System.out.println(“You failed and your grade is ” + grade);
}
}
}