Thursday, January 20, 2011

this.onXhrStateChange.bind is not a function

Recently I require to work with the proxy injection mode. And as soon as I endup setting selenium for proxy injection mode I got following error.

this.onXhrStateChange.bind is not a function on session  ad4cf7d3106f4f379a27af514bd1ff5d

I tried a lot and finally got the solution. Though using this solution I am not getting above error anymore, browser is opening but some of the other command is failing, like waitforpagetoload.

Solution:
  1.  Download the source code of selenium-java-client-driver.Jar file and extract that into one folder 
  2. Open the file DefaultSelenium.Java and replace the "public void open(String url)" function with the following.
    public void open(String url) {
                    commandProcessor.doCommand("open", new String[] {url,"true"});
        } 
  3. Recompile the file and create new JAR 
  4. Replace the JAR with original JAR, Build the project again and then Run.

Thursday, December 30, 2010

Selenium - Handle Upload Dialog

Download
Handle_File_Upload.exe



Following is the Autoit Script to handle upload dialog box.

;--------------------------------------------------------------------
;~ File_Upload_FF.au3
;~ Purpose: TO handle the file Upoload dialog
;~ Usage: File_Upload_FF.exe "Dialog Title" "Path of the file"
;~ Create By: Gaurang Shah
;~ Email: shahgomji@gmail.com
;--------------------------------------------------------------------

AutoItSetOption("WinTitleMatchMode","2") ; set the select mode to select using substring

if $CmdLine[0] < 2 then
; Arguments are not enough
msgbox(0,"Error","File_Upload_FF.exe 'Dialog Title' 'Path of the file'")
Exit
EndIf

; wait Until dialog box appears
WinWait($CmdLine[1]) ; match the window with substring
$title = WinGetTitle($CmdLine[1]) ; retrives whole window title
WinActivate($title)

WinWaitActive($title)
ControlSetText($title,"","Edit1",$CmdLine[2])
ControlClick($title,"","&Open")

You need to download Autoit in order to run this script else you can download the EXE uploaded here.

To know how to call this EXE from JAVA read the following blogpost.
http://qtp-help.blogspot.com/2009/07/selenium-handle-dialogs.html