Jump to content
Sign in to follow this  
veerendra

FireFox Tab Verification

Recommended Posts

veerendra

#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
JohnOne

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
veerendra

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
Shrapnel

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
Shrapnel

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
veerendra

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
JohnOne

$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
Shrapnel

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
Shrapnel

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
veerendra

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
Shrapnel

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
veerendra

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
veerendra

#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  

  • Similar Content

    • rudi
      By rudi
      Hello,
      usually I do Win automations, so I have no skills at all to handle HTML forms :-/
      The script to catch and syntax check  the required information from Excel is done.
      Now I'd like to automate the upload using this form, too:
       
      http://flashcardsdeluxe.com/flashcards/Upload.aspx
      What browser is easiest to do so? (IE, Chrome, FF) The Values $DeckCode, $DeckName, $DeckDefinition shall go to their HTML form fields finally "click" the button "upload flashcards" <table width="70%" class="cssCenter" border="0"> <tr> <td style="width: 1%">Deck&nbsp;Code</td> <td style="width: 100%"><input name="ctlDeckCode" type="text" id="ctlDeckCode" style="width:50%;" /> (no spaces allowed)</td> <td></td> </tr> <tr> <td style="width: 1%">Deck&nbsp;Name</td> <td style="width: 100%"><input name="ctlDeckName" type="text" id="ctlDeckName" style="width:50%;" /> (optional)</td> <td style="width: 1%" align="right"><input type="submit" name="ctlUpload" value="Upload Flashcards" id="ctlUpload" /></td> </tr> <tr> <td valign="top" style="padding-top: 5px" >Flashcard&nbsp;Text</td> <td colspan="2"><textarea name="ctlFlashcardText" rows="2" cols="20" id="ctlFlashcardText" style="height:280px;width:100%;"></textarea></td> </tr> </table> If someone kindly could jump in showing how to address just one of the input fields and how to "click" the "upload flashcards" button, I should be able to do the rest myself.
      TIA, Rudi.

    • Faraz
      By Faraz
      I have to open a URL on Mozilla Firefox , cursor is by default userid textbox, had to send userid, send tab, send pwd with flag 1 , send tab, send Enter.
      But Script is Failing to take Password.
      Any Help
       
      #include <Constants.au3>
      #include <IE.au3>
      #include <PassMask.au3>
      If $CmdLine[0] <> 3 Then
          MsgBox($MB_OK, "Usage", "ps_weblogin_FireFox <Url> <Browser Title> <Text to Send>")
      Else
         web_login($CmdLine[1], $CmdLine[2], $CmdLine[3])
      EndIf
      Func web_login($bt_url, $bt_Title, $bt_SendText)
          Local $ff = Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe " & $bt_url)
              WinWaitActive($bt_Title)
          Sleep(2000)
          ControlSend("","","",$bt_SendText)
      EndFunc
      _______________________________________________
      _______________________________________________
      Func Mask_Password($Password)
          $MaskPassword = $Password
          $MaskPassword = StringReplace($MaskPassword, "#", "||||||#@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "!", "||||||!@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "+", "||||||+@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "^", "||||||^@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "{", "||||||{@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "}", "||||||}@@@@@@")
          $MaskPassword = StringReplace($MaskPassword, "||||||", "{")
          $MaskPassword = StringReplace($MaskPassword, "@@@@@@", "}")
          Return $MaskPassword
      EndFunc
    • Marc
      By Marc
      Profiler - yet another backup script for Firefox and Thunderbird profiles
      It automatically detects the last recently used profile directories of Firefox and Thunderbird (installed versions, no portables).
      Clicking the Backup-Button creates a complete Backup of the found profiles with a timestamp.
      Restore deletes the according profile dir and extracts the content of the selected archive into the profile directory.
      Uses Winrar as compression tool, but feel free to change it to your needs
      Best regards
      Marc

      Profiler.au3
    • BOUNCER
      By BOUNCER
      I'm trying to get the output data from https://www.guilded.gg but it uses a web app that generates that output on the fly and this doesn't show up in the page source.
      Only in web inspector of each browser does this data show up. How do I read this data in autoit (equivalent to the web inspector)
       
      thank you
    • Pao
      By Pao
      Hello, I've recently updated from Firefox 50 to 54.0.1.
      My Autoit script that previously worked fine, now seems to have erratic problems.
      It's almost as if some Send() commands are sometimes skipped when dealing with the Firefox UI (it's still mostly fine on the actual pages).

      To temporarly fix the problem, I had to put some Sleep(200) pauses and avoid grouping keys together (e.g: TAB 2), but I'm not exactly sure about the correct way to deal with this..
      Could this be caused by the new multiprocess feature? (e10s)
      Are there better Autoit commands or rules that I should use?
       
×