Jump to content

How can i get a Modal Dialog's text


Recommended Posts

Hi Mates,

I am Newbie to AutoIT and Watir, before that i was using QTP for our testing process, recently i have started the QTP scripts into Watir.

I am working in a web application, where there are so many Modal Dialogs have been used to covey error message. I tried to get the popup text by using Watir but i cant get anything, only nil value i got. When i tried the same with Autoit i got the url in the Modal dialog. Please let me know if any ways are available to access the Modal dialog's text.

@ie.frame(:id,"wfFrame").button(:id,"PageActionPane_btnSubmit").click_no_wait

sleep 10
puts title1 = autoit.WinGetTitle("")
puts autoit.WinWait(title1,3)
puts autoit.WinGetText(title1)

The above code returns the window handle, title correctly. But it returns the url only from the Modal Dialog. please see the attached screen shot of the Modal dialog.

If is it possible in Autoit please let me know about the way and code.

Thanks.

post-43709-1228740506_thumb.jpg

Link to comment
Share on other sites

Hi Mates,

I am Newbie to AutoIT and Watir, before that i was using QTP for our testing process, recently i have started the QTP scripts into Watir.

I am working in a web application, where there are so many Modal Dialogs have been used to covey error message. I tried to get the popup text by using Watir but i cant get anything, only nil value i got. When i tried the same with Autoit i got the url in the Modal dialog. Please let me know if any ways are available to access the Modal dialog's text.

@ie.frame(:id,"wfFrame").button(:id,"PageActionPane_btnSubmit").click_no_wait

sleep 10
puts title1 = autoit.WinGetTitle("")
puts autoit.WinWait(title1,3)
puts autoit.WinGetText(title1)

The above code returns the window handle, title correctly. But it returns the url only from the Modal Dialog. please see the attached screen shot of the Modal dialog.

If is it possible in Autoit please let me know about the way and code.

Thanks.

I've used the MouseDrag option before from the beginning of the text to the end and then done a CTRL C to clipboard. if you can copy the text then read up on the clipboard functions...life saver for me. Failing this will mean having to use OCR technique, which I personally haven't tried so maybe another user can assist. Edited by IndyUK
Link to comment
Share on other sites

I've used the MouseDrag option before from the beginning of the text to the end and then done a CTRL C to clipboard. if you can copy the text then read up on the clipboard functions...life saver for me. Failing this will mean having to use OCR technique, which I personally haven't tried so maybe another user can assist.

Thanks for instant reply, but Ctrl C is not working....

Link to comment
Share on other sites

And what if you will try to get the source from that URL? :)

#Include <Inet.au3>

$sSource = _InetGetSource("http://10.1.193.109/itrade/Message.html")
ConsoleWrite($sSource)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Thanks for instant reply, but Ctrl C is not working....

Do you mean that you're not able to highlight the text? If you can manually highlight the text then you should be able to try the following...

_ClipBoard_Empty();empty clipboard
MouseClickDrag("Left", 35, 187, 165, 187, 30);drag mouse pointer over case ref
Send("^c");copy the case ref to clipboard

That copies from a start screen location to a end screen location

If the copy worked then you should be able to paste into Notepad. If you want to see the value copied via AutoIt then..

_ClipBoard_GetData()

Hope this helps.

Link to comment
Share on other sites

And what if you will try to get the source from that URL? :)

Thanks,

When i navigate to the url it shows the layout of the Modal Dialog without the Error message. Ref the attachments. In the HTML tag error message passed as a object, so i can not access it. :-(

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Information&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title>
   
    <link href="App_Themes/grey/Styles.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
    function ShowMessage()
    {
        var messageDetails = new Object();
        messageDetails = window.dialogArguments;
        document.getElementById('spnMessage').innerHTML = '<br/><br/>' + messageDetails.message;
    }
    </script>

</head>
<body class="popuppage" onload="ShowMessage();">
    <form id="form1" runat="server">
        <div align="center"  style="margin-top:20px">
            <div class="popupcontent" style="margin-left:7px;width: 420px; height: 130px; vertical-align: middle">
                <div style="height: 84px;">
                    <br />
                    <div align="center">
                        <div style="float: left; padding: 15px;">
                            <img src="Images/successmessage.png" />
                        </div>
                        <div style="padding-right: 10px;">
                            <span class="hlptopic" id="spnMessage"></span>
                        </div>
                    </div>
                </div>
                <div class="popupClose" align="right">
                    <div style="top: 10px; position: relative; padding-right: 20px">
                        <input type="button" tabindex="1" class="btn" value="Close" onclick="window.close();" />
                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>

post-43709-1228797147_thumb.jpg

Edited by Prince3105
Link to comment
Share on other sites

Do you mean that you're not able to highlight the text? If you can manually highlight the text then you should be able to try the following...

In the Modal Dialog, i can able to click the "Close" button only, other any functions are not working especially "Ctrl C".

If you see the HTML tag, the error message passed as a object. Is it possible to access javascript in autoIt ?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...