Tag Archives: getProfile

How to Work with browser cookies – getCookies, deleteCookieNamed, and deleteAllCookies using selenium webdriver?

problem?

How to Work with browser cookies – getCookies, deleteCookieNamed, and deleteAllCookies using selenium webdriver?

 

Solution: 🙂

 

Set testCookie = myTestDriver.manage().getCookies();

Set testCookie = myTestDriver.manage().getCookies();

 

 

class Cookie

 

deleteCookieNamed deleteAllCookies

 

import java.util.Iterator;
import java.util.Set;

import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class CookieManagment {
 public static void main(String[] args) {
 ProfilesIni allProfiles = new ProfilesIni();
 FirefoxProfile myProfile = allProfiles.getProfile("MyTestProfile");
 myProfile.setPreference("capability.policy.default.Window.frameElement.get","allAccess");

 WebDriver myTestDriver = new FirefoxDriver(myProfile);
 myTestDriver.manage().window().maximize();

 myTestDriver.get("http://linkedin.com");


 //getCookies() - Get all the cookies for the current domain.
 Set<Cookie> testCookie = myTestDriver.manage().getCookies();

 Iterator<Cookie> iter= testCookie.iterator();

 while(iter.hasNext()){
 Cookie C = iter.next();
 System.out.println(C.getName()+"-------------------" + C.getPath()+"--------------------"+ C.getDomain()+"----"+C.getValue()+"---"+C.getExpiry());

 }

 //deleteCookieNamed(java.lang.String name)- Delete the named cookie from the current domain.
 myTestDriver.manage().deleteCookieNamed("JSESSIONID");
 System.out.println("------------------------------------------------------------------------------------");

 testCookie = myTestDriver.manage().getCookies();

 iter= testCookie.iterator();

 while(iter.hasNext()){
 Cookie C = iter.next();
 System.out.println(C.getName()+"-------------" + C.getPath()+"------------"+ C.getDomain()+"----"+C.getValue()+"---"+C.getExpiry());

 }


 //deleteAllCookies() - Delete all the cookies for the current domain.
 myTestDriver.manage().deleteAllCookies();
 testCookie = myTestDriver.manage().getCookies();

 iter= testCookie.iterator();
 while(iter.hasNext()){
 Cookie C = iter.next();
 System.out.println(C.getName()+"-------------" + C.getPath()+"------------"+ C.getDomain()+"----"+C.getValue()+"---"+C.getExpiry());

 }

}

}

How to Handle untrusted SSL certificates using selenium webdriver?

What is the problem?

How to Handle untrusted SSL certificates using selenium webdriver?

 

Solution:

When this appears?

If the site has a security certificate, but it is wrong / outdated, then Firefox will warn you that someone might be trying to deceive you. You can bypass the message by clicking the “Add an exception” button, and then retrieving the certificate and viewing it.

Firefox certificate Error

 

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class testHandleFireFoxcertificatesIssue {
 public static void main(String[] args) {

 //Class ProfilesIni details -&gt; http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
 ProfilesIni allProfiles = new ProfilesIni();

 //Class FirefoxProfile -&gt; http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
 // Use FirefoxProfile Constructor
 FirefoxProfile myProfile = allProfiles.getProfile(&quot;CertificateIssue&quot;);

 myProfile.setAcceptUntrustedCertificates(true);
 myProfile.setAssumeUntrustedCertificateIssuer(false);
 WebDriver myDriver = new FirefoxDriver(myProfile);

 myDriver.get(&quot;http://www.paypal.com&quot;);

}

}

How to Handle untrusted SSL certificates using selenium webdriver

How to Handle untrusted SSL certificates using selenium webdriver?

 

Get code from PasteBIN

 

How Selenium webdriver use existing firefox profile ?

Open firefox based on firefox profile using FirefoxProfile class

Open firefox based on firefox profile using FirefoxProfile class

 

  • Create object of Class ProfilesIni
  • Call Method getProfile of Class ProfilesIni
  • Which return a object of the type Class FirefoxProfile
  • So Create new Class FirefoxProfile object and assign to it.

 

FF profile How it works

 import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

public class testFirefoxProfile {
 public static void main(String[] args) {

 //Class ProfilesIni details -> http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
 ProfilesIni allProfiles = new ProfilesIni();

 //Class FirefoxProfile -> http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
 // Use FirefoxProfile Constructor
 FirefoxProfile myProfile = allProfiles.getProfile("MyTestProfile");


 WebDriver myDriver = new FirefoxDriver(myProfile);

 myDriver.get("http://twitter.com");

 System.out.println("What is my URL --------------->" + myDriver.getCurrentUrl());

 System.out.println("What is my Page title ----------->" + myDriver.getTitle());

 System.out.println("");
 myDriver.quit();

}

}

Pupunzi

For a better web

Tech

News and reviews from the world of gadgets, gear, apps and the web

VentureBeat

News About Tech, Money and Innovation

Digital Inspiration

Tips and tutorials around all things tech.

Thinkwareglobal's Blog

Just another WordPress.com weblog

Kenazari's Blog

Just another WordPress.com weblog

Richfowler1's Blog

Just another WordPress.com weblog

Romaicus's Blog

Just another WordPress.com weblog

botlaguduri

Just another WordPress.com site

chandanag89

Just another WordPress.com site

meghshetty

Just another WordPress.com site

digitalmediaexpert

digital media expert blog

Thinking in Silverlight

Silverlight/WPF/Windows 8 Store App

Different Journeys

Let's make life easier!

LAW RESOURCE INDIA

LEGAL RESOURCE CENTRE / COURT JUDGMENTS / LEGAL ARCHIVES

BookConnect

Promoting Indian language Books

Mary Ann M-P's Blog

Selenium: My Take

Actively Lazy

Software, crafted with passion

SAPonPower

An ongoing discussion about SAP infrastructure

SAP Career

Your Career Mentor

hrsapcertification

Just another WordPress.com site

The secret product manager

Thoughts about product management, SUSE, Linux, ARM processors, Cloud, AIX, Power Systems, and other things that interest me

Sap Certification Material . Com

Quality store for sap software and courses

Simon Les Flex's Blog

SAP Process Integration Specialist - NOW WE CAN DO BETTER!

Oracle Technologies Primer

An Oracle Fusion Middleware and iPaaS blog!

Gilberto Holms

Java, Middleware, SOA Architecture Blog

The Skeleton

Java code skeletons, tips and pointers

J@n van Zoggel

integration, innovation & random technology stuff

The Pragmatic Integrator

Hints and tips from a pragmatic integration specialist

briskwalk

The pace of life..

Optimalbg's Blog

Just another WordPress.com site

IT Jobs in USA

Keep the track of this Blog if you are looking out for some good Opportunities to work in USA....

Referral Jobs | Right Place to Get a Job

Hurry you are one Click away to get a job - Fresher Jobs for 2012, 2013 fresher’s and also high paid jobs for well Experienced IT professionals on Referal jobs.

eccinternational.wordpress.com/

ISO Consulting | ISO 27001 | ISO 20000 | CMMI | BCM | GRI Sustainability Reporting & Assurance | eLearning | Trainings | Philippines

Michael Korn's Blog

Musings on Life, Career, Faith and Technology

WORKINGWITHQTP

Just another WordPress.com weblog

Solutions365

.net, WCF, Unity, IOC, SQL

SQA and Testers Blog

Just another WordPress.com weblog

Expertqtp's Weblog

Just another WordPress.com weblog

Sai Chamarthi

Experienced Testing Professional

saxenavinay

A great WordPress.com site

Suresh4qtp's Blog

Just another WordPress.com site

jonah95hill

This WordPress.com site is the cat’s pajamas

It's always something...

Just another WordPress.com weblog

Faculty of Information Technology - Lê Ngọc Tiến

Be Yourself! Simplify Our Goals! Nothing is Impossible!

Anti-Malware Testing

Thoughts on security product testing past and present

Methods & Tools

Practical knowledge for the software developer, tester and project manager