Selenium webdriver is used to automate web applications. Web applications generally starts with http://www.example.com......But some websites like internal websites or banking or secured web sites will starts with https://www.example.com.
Below is one of the approach to handle https site while you are running from InternetExplorer.
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class HttpsTest {
WebDriver driver;
@Test
public void httpsTest() throws Exception {
driver.get("https://esupport.satyam.com/main.aspx");
//Java script to click the link
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
Thread.sleep(5000);
//assert the title of the page
Assert.assertEquals(driver.getTitle(), "Welcome to Tech Mahindra Universe");
System.out.println("asssert successfull");
Thread.sleep(5000);
}
@BeforeTest
public void beforeTest() {
//launch Internet explorer
System.setProperty("webdriver.ie.driver", "F:\\Jar\\IEDriverServer.exe");
driver=new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterTest
public void afterTest() {
driver.close();
driver.quit();
}
}
==============================================================
Hope this post will be useful......
Here we need to click the second option to go in to website.
Here we are taking help of Java script to click the second link
Below is the code for handling https site..
===============================================
package scripts;import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class HttpsTest {
WebDriver driver;
@Test
public void httpsTest() throws Exception {
driver.get("https://esupport.satyam.com/main.aspx");
//Java script to click the link
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
Thread.sleep(5000);
//assert the title of the page
Assert.assertEquals(driver.getTitle(), "Welcome to Tech Mahindra Universe");
System.out.println("asssert successfull");
Thread.sleep(5000);
}
@BeforeTest
public void beforeTest() {
//launch Internet explorer
System.setProperty("webdriver.ie.driver", "F:\\Jar\\IEDriverServer.exe");
driver=new InternetExplorerDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterTest
public void afterTest() {
driver.close();
driver.quit();
}
}
==============================================================
Hope this post will be useful......
Hi,
ReplyDeleteWhile running the test cases in webdriver ( firefox browser ), am getting SSL certificate error. Even after adding the below code
FirefoxProfile profile = new ProfilesIni().getProfile("profile name");
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
driver =new FirefoxDriver(profile);
driver.get(" ");
Any suggestion is much appreciated.