What is the usage of loading firefox with profile - selenium-webdriver

My question may look strange or weak, but can you please let me know what are the real usage of loading firefox with any profile?
Load firefox with Plug-in(Can someone explain some real scenario). I never come across this situation.
I think to resolve SSL Certificate issues. (Nowadays none of bank or financial sites doesnt show these certificate warnings). Where we use this to firefox with profile?
Can you please let us know if there are any other places(realtime scenarions) we may need firefox with profile?

If we donot define any profile then Selenium Webdriver uses default fresh firefox profile.
But in some scenarios, we have specific requirements for browser. For example..
we can expect it to have history records
we may want it to remember passwords
we may need to utilize some firefox plugins during our webdriver tests
so on..
All above come under personal profile settings, which can be defined in custom profile in our selenium project.
For more details check: http://toolsqa.com/selenium-webdriver/custom-firefox-profile/
Between, I will suggest you to join https://sqa.stackexchange.com/ that is forum specifically for SQA related questions. You will have greater chances of getting answers there.

profiling helps us update the preferences within Firefox.
We can do this by instantiating a Firefox Profile object and then update the settings.
We will then need to pass this object into Firefox Driver which will load the profile with your defined settings.
For example:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.Test;
public class FireFoxProfileExample {
WebDriver driver;
#Test
public void testExamples(){
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.startup.homepage",
"http://www.google.com");
driver = new FirefoxDriver(profile);
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("100");
}
Hope this helps you!!!

Related

How we can clear the cookie for Internet Explorer for Selenium automation

We are currently automating using IE browser using Selenium webdriver. in order to run our test cases we need to clear the cookie from Registry and run test case to start from page 1. Can you help me out to how we can do?
I hope question is not related to registry. There are two ways which doesn't need to work with registry key to clear cookies are:
set capability ie.ensureCleanSession to true
iexplorer.additional.capabilities={'ie.ensureCleanSession':true}
Through code delete all coockies
driver.manage().deleteAllCookies();
Right place to put #2 is in driver listener onInitialize method.
public void onInitialize(QAFExtendedWebDriver driver){
driver.manage().deleteAllCookies();
}

How to send SendKeys to Windows form in python script?

I'm doing automation scripting in Python for my desktop application.
In that I'm sending TAB key/any key to my windows form. But I'm not able to find handle of that Windows form in my Python script.
Here is the sample code snippet :
__author__ = 'juhis'
import SendKeys
import sys
import os
from Tkinter import *
import ctypes
import win32gui
import pywinauto
pwapp = pywinauto.application.Application()
whandle = pywinauto.findwindows.find_windows(title_re='Form1',class_name='WindowsForms10.Window.8.app.0.2bf8098_r13_ad1')[0]
window1 = pwapp.window_(handle=whandle)
window1.SetFocus()
SendKeys.SendKeys("""{PAUSE 2}""")
SendKeys.SendKeys("""{TAB 2}{PAUSE 2}{ENTER}""")
Please help me to figure out the issue.
-Thanks
The code can be re-written simpler:
import pywinauto
app = pywinauto.application.Application().connect(title_re='Form1')
Form1 = app.Window_(title_re='Form1', class_name='WindowsForms10.Window.8.app.0.2bf8098_r13_ad1')
Form1.SetFocus()
Form1.TypeKeys("{PAUSE 2}")
Form1.TypeKeys("{TAB 2}{PAUSE 2}{ENTER}")
TypeKeys automatically sets a focus to the Form1 and types the keys. SendKeys doesn't set a focus because it's not aware about the window. That's probably why it doesn't work with SendKeys.
[EDIT] Of course you need to run the script as Administrator.
I got a fixed for this issue. The mistake I was doing is that, I was not running my script as Administrator. So that's why SendKeys event were not happening.
But when I ran my script as Administrator, SendKeys event successfully sent to Windows form.
Thanks Vasily for your help.

Selenium webdriver does not open the most recent iteration of webpage?

I trying to make a selenium script that checks a real estate website and emails any new properties. all of the old properties are stored in a databases, the listings are cross checked against the database and new ones are emailed.
I got it working pretty well, however I noticed that if I myself navigate to said real estate website manually I see 3-4 new listings. When I run the script through task manager and the driver opens the page through firefox, the driver does not see those newly listed properties! Why is this happening? Thanks
It is possible your browser is caching the outdated information.
Try calling:
driver.manage().deleteAllCookies();
After instantiating your driver, and before navigating to your page.

How to import java.awt.Robot & java.awt.event.KeyEvent in python binding for selenium and its sample usage

Setup :python bindings for selenium 2.45.0 ,IEserver driver2.45.0(x86),python 2.7.9 ,window 7 64 bit
Problem:Trying to handle security based windows popup(OS) in a web application(input password and click ok) .
Tried
1. alert handling like this work , able to enter password
alert = driver.switch_to_alert()
alert.send_keys("1246545")
but now following doesn't work , not able to click ok or press ENETER
alert.send_keys(Keys.ENTER)
alert.send_keys("1246545"+Keys.ENTER)
2.Autoit , dont want to use it , will be last option
3.seen some solution like using Robot class
Robot rb =new Robot();
rb.keyPress(KeyEvent.VK_ENTER);
I am new to java , dont know how to import these packages in python bindings , this is how they do in selenium.
import java.awt.Robot;
import java.awt.event.KeyEvent;
want to know how to import above pacakages in python bindings for selenium , some working examples are
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
As an alternative approach, you may like to use this special URL format to pass the credentials in the HTTP Authorization header.
http://username:password#example.com/

Selenium Webdriver: download files on firefox using DesiredCapabilities class

Is there an alternative to firefox profile to download files, i.e. through desiredcapability on selenium webdriver?
I want to download files from a website but through desiredcapabilities.
So one piece of code is applicable accross all the browsers.
In theory, you could create a AugmenterProvider and pass it to the Augmenter class but I have not done so and its beyond my skill.

Resources