Jump to content
Sign in to follow this  
veerendra

FireFox Tab Verification

Recommended Posts

#include <Excel.au3>
Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
Opt("MouseCoordMode",0)
#region ---Au3Recorder generated code Start (v3.3.7.0)  ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc


#endregion --- Internal functions Au3Recorder End ---


Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"')
Sleep(1000)
_WinWaitActivate("Google - Mozilla Firefox","")
$pass=_WinWaitActivate("Google - Mozilla Firefox","")
if $pass=_WinWaitActivate("Google - Mozilla Firefox","") Then

    _ExcelWriteCell($oExcel, "Pass", 1, 1) ;Write to the Cell
Elseif $pass=_WinWaitActivate("Google - Mozilla Firefox","") Then

    _ExcelWriteCell($oExcel, "Fail", 1, 1) ;Write to the Cell
EndIf
Sleep(1000)
MouseClick("left",236,95,1)
Sleep(1000)
Send("{BACKSPACE}www.jettysoft.com{DEL}{ENTER}")
Sleep(1000)
_WinWaitActivate("JettySoft - Mozilla Firefox","")
Sleep(1000)
MouseClick("left",1256,15,1)
Sleep(1000)
_WinWaitActivate("Confirm close","")
Sleep(1000)
MouseClick("left",178,115,1)
#endregion --- Au3Recorder generated code End ---

Hi, i am trying to pass or fail to excel, when i am opening  google i am trying to send the pass to excel and if it opening the different url i am trying to send fail.

But i couldn't able to put if condition and verifying conditions. Please help i am facing this problem from months

Share this post


Link to post
Share on other sites

I cannot understand your post, but this makes less sense.

if $pass=_WinWaitActivate("Google - Mozilla Firefox","") Then

    _ExcelWriteCell($oExcel, "Pass", 1, 1) ;Write to the Cell
Elseif $pass=_WinWaitActivate("Google - Mozilla Firefox","") Then

    _ExcelWriteCell($oExcel, "Fail", 1, 1) ;Write to the Cell
EndIf

Both conditions appear to me, to be the same.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

if $pass=_WinWaitActivate("Google - Mozilla Firefox","") Then    
 _ExcelWriteCell($oExcel, "Pass", 1, 1) ;Write to the Cell
 Elseif $pass=_WinWaitActivate("Yahoo Canada - Mozilla Firefox","") Then     
_ExcelWriteCell($oExcel, "Fail", 1, 1) ;Write to the Cell EndIf

I tried in this way but else if condition is not working. i don't Know, what is UDF. how to use it? Could any one explain to me

Share this post


Link to post
Share on other sites

I agree with JohnOne. Not sure what your goal is.

Are you trying to use excel in Google docs and not with the actual Microsoft Excel program?

Share this post


Link to post
Share on other sites

you are setting $pass equal to your function "_WinWaitActivate" but that function returns no values.

Try changing your function like this so you are returning a value

WinWaitActive returns the following:

Success: Returns handle to the requested window. Failure: Returns 0 if timeout occurred.
Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    Return WinWaitActive($title,$text,$timeout)
EndFunc
Edited by Shrapnel

Share this post


Link to post
Share on other sites

sorry for that,

i am trying to test , when i open firefox it should open default webpage (www.google.com) if it opens default webpage then my test case is passed so now i want to report in to excel that it is passed.  or if it opens the different url other  than (www.google.com) then my test case is failed so i want to report it as failed.

Edited by veerendra

Share this post


Link to post
Share on other sites

$PID = Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"')
ProcessWait($PID)
Sleep(1000); might want to wait longer.

If _IsGoogle($PID) Then
    ;do stuff
    MsgBox(0,0,"Yay")
    Exit
EndIf

;do other stuff
MsgBox(0,0,"Booo")

Func _IsGoogle($PID)
    Opt("WinTitleMatchMode",2)
    Local $hWnd = _GetHwndFromPID($PID)
    Local $WinTitle = WinGetTitle($hWnd)
    If StringInStr($WinTitle, "Yahoo -") Then
        Return 1
    EndIf
    Return 0
EndFunc

Func _GetHwndFromPID($PID)
    ;http://www.autoitscript.com/forum/topic/86680-pid-window-handle-hwnd-conversion/#entry621521
    $hWnd = 0
    $stPID = DllStructCreate("int")
    Do
        $winlist2 = WinList()
        For $i = 1 To $winlist2[0][0]
            If $winlist2[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
                If DllStructGetData($stPID, 1) = $PID Then
                    $hWnd = $winlist2[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(100)
    Until $hWnd <> 0
    Return $hWnd
EndFunc ;==>_GetHwndFromPID


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

JohnOne is too quick for me lol. i was just about to post the exact same code

Edit: But why are you looking for "Yahoo - "?

Edited by Shrapnel

Share this post


Link to post
Share on other sites

Here is the version that I was working on (just posting because it was slightly different):

#include <Excel.au3>

Local $oFireFox = Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"')
ProcessWait($oFireFox)

Sleep(5000)

Local $hwndFireFox = _GetHwndFromPID($oFireFox)

If Not WinActive($hwndFireFox) Then WinActivate($hwndFireFox)

Local $FireFoxTitle = WinGetTitle($hwndFireFox)

Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

If $FireFoxTitle = "Google - Mozilla Firefox" Then
    _ExcelWriteCell($oExcel, "Pass", 1, 1) ;Write to the Cell
Else
    _ExcelWriteCell($oExcel, "Fail", 1, 1) ;Write to the Cell
EndIf

Exit

Func _GetHwndFromPID($PID)
    ;http://www.autoitscript.com/forum/topic/86680-pid-window-handle-hwnd-conversion/#entry621521
    $hWnd = 0
    $stPID = DllStructCreate("int")
    Do
        $winlist2 = WinList()
        For $i = 1 To $winlist2[0][0]
            If $winlist2[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
                If DllStructGetData($stPID, 1) = $PID Then
                    $hWnd = $winlist2[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(100)
    Until $hWnd <> 0
    Return $hWnd
EndFunc ;==>_GetHwndFromPID

Share this post


Link to post
Share on other sites

i am testing the windows application, it has the feature of parental control. i will block a website(www.google.com) to open, know i want to test the website is blocked or not.

so here i will pass different url(yahoo) so it should open yahoo. but www.google.com should be blocked.

Share this post


Link to post
Share on other sites

Have you tried either of the scrips that JohnOne or I posted? They should do the basics of what you are looking for.

If you need more complicated test cases, then look at the links that Danp2 posted ()

Share this post


Link to post
Share on other sites

i tried your post, when i tried to run, it is just opening the firefox  after that it is not doing any thing, it didn't send "pass" in to excel.

Share this post


Link to post
Share on other sites

#include <Excel.au3>
Local $oExcel = _ExcelBookNew()
Opt("WinTitleMatchMode", 2)
Run('"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"')
WinWaitActive("Firefox")
Sleep(5000)
;MsgBox(1, "Done", WinGetTitle("[active]"))
Local $title = WinGetTitle("[active]")
If (StringInStr($title, "Google - Mozilla Firefox", 0)) = 0 Then
    _ExcelWriteCell($oExcel, "Pass", 1, 1) ;Write to the Cell
   MsgBox(1, "Done", "Test Failed")
Else
    _ExcelWriteCell($oExcel, "Fail", 1, 1) ;Write to the Cell
   MsgBox(1, "Done", "Test Passed")
EndIf

i tried this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
    • By picorico2
      Hi all, 
       
      I´m trying to use the command "WD_LoadWait" because I want to pause the script until the web page fully loads in Firefox but I don´t know how to use it.
      Here´s the full help
      ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_LoadWait ; Description ...: Wait for a browser page load to complete before returning ; Syntax ........: _WD_LoadWait($sSession[, $iDelay = 0[, $iTimeout = -1[, $sElement = '']]]) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $iDelay - [optional] Milliseconds to wait before checking status ; $iTimeout - [optional] Period of time to wait before exiting function ; $sElement - [optional] Element ID to confirm DOM invalidation ; Return values .: Success - 1 ; Failure - 0 and sets the @error flag to non-zero ; Author ........: Dan Pollak ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_LoadWait($sSession, $iDelay = Default, $iTimeout = Default, $sElement = Default) Local Const $sFuncName = "_WD_LoadWait" Local $iErr, $sResponse, $oJSON, $sReadyState   If $iDelay = Default Then $iDelay = 0 If $iTimeout = Default Then $iTimeout = $_WD_DefaultTimeout If $sElement = Default Then $sElement = ""   If $iDelay Then Sleep($iDelay)   Local $hLoadWaitTimer = TimerInit()   While True If $sElement <> '' Then _WD_ElementAction($sSession, $sElement, 'name')   If $_WD_HTTPRESULT = $HTTP_STATUS_NOT_FOUND Then $sElement = '' Else $sResponse = _WD_ExecuteScript($sSession, 'return document.readyState', '') $iErr = @error   If $iErr Then ExitLoop EndIf   $oJSON = Json_Decode($sResponse) $sReadyState = Json_Get($oJSON, "[value]")   If $sReadyState = 'complete' Then ExitLoop EndIf   If (TimerDiff($hLoadWaitTimer) > $iTimeout) Then $iErr = $_WD_ERROR_Timeout ExitLoop EndIf   Sleep(100) WEnd   If $iErr Then Return SetError(__WD_Error($sFuncName, $iErr, ""), 0, 0) EndIf   Return SetError($_WD_ERROR_Success, 0, 1) EndFunc
       
      Any sugestions or examples?
    • By water
      Internet Explorer is nearly dead, newer versions of Firefox can't any longer be automated using Stilgar's FF UDF.
      Hence more and more users (including me) need to look at automating Webbrowsers using WebDriver.
      That's why I have started to create a tutorial in the wiki.
      It should describe all necessary steps from intallation to usage.

      I'm still collecting ideas for the tutorial - that's where you come into play.
      What do you expect to see in such a tutorial?
      Which browsers should be covered (Firefox, Chrome and Edge are settled)? Any questions for the FAQ? Which (high level) coding examples do you expect (like "How to attach to a running browser instance") ... Like to see your comments
       
      ToDo-List:
      Add "Tools" section and add ChroPath plugin. Done. FAQ: "How to attach to a running browser instance". Done. Explain the difference between iuiautomation, iaccessible, autoit, webdriver. Done. The AutoIt FAQ 40 has been extended. Detailed description of each function. Done Example for "how to deal with downloading". Use function _WD_DownloadFile. Example for "how to deal with popups (alerts, print or save dialog). Use function_WD_AlertRespond to respond to a user prompt. Example for "how to deal with multiple tabs". Use functions _WD_NewTab (create a new tab), _WD_Window (close or switch to a tab) and _WD_Attach (attach to existing tab).
    • By ThePoro
      Hi everyone.
      I want to ask about this : 
      I want it runs from 1 to 100 and It opens 10 firefox profiles then access youtube. After I close a firefox window, the loop runs and wait for another window close until loop ends
      I have a loop like this.
      Func launch() Local $from = Int(GUICtrlRead($input1)) Local $to = Int(GUICtrlRead($input2)) If $to <> "" Then While $from <= $to Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") $to=$to+1 WEnd Else Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") EndIf EndFunc Is there any solution?
      Thank you!
    • By nooneclose
      my FF.au3 does get included but my script does not open firefox. 
      here is my code so far:
      #include <FF.au3> _FFStart("https://www.google.com", Default, 0) I am using firefox portable version 52.0 Any and all help would be greatly appreciated.  
      The code runs but nothing happens. I think the FF.au3 cannot find or connect to the firefox portable.  
×
×
  • Create New...