![]()
API Guide - File |
Courses in c#, ruby, shell scripting, Software testing courses and more
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Class | WET::WebFile |
| In: |
WebFile.rb
|
| Parent: | WebObject |
# Class to represent a Filefield object on the browser
The controls that allow you to upload files are the File objects.
Create a new instance of the WebFile object.Scripts should not directly try to create instances of this object.
Instead they should use the File("args)method of the WebContainer.File(*args)to create an instance.
The controls that allow you to upload files are the File objects.
1) Getting a reference of the required File
The syntax to get the reference of a File is :
Container.File("name:=value")
Where
Container is a Browser, Frame, Table or any other container that can hold HTML elements as its children.
name is the name of the attribute to be checked.
value is the value of that attribute.
Browser("title:=Controls").File("label:=Upload audio")
The commonly used attributes to identify a radio are:
name The HTML name attribute of the File control
id The HTML id attribute of the File control
label The label for this File control
Tip : To construct the definition for a File control, use the container's show_objects('File') method. Then pick
the one that is appropriate for the File control of interest and copy paste it into your script.
Check whether the Filefield actually exists on the page.If the filefield actually does exist,then prints out a success message in the test report.If it doesn’t exist,then it prints out a failure in the report.
Checks whether the Filefield *does not* exist on the page.If the filefield does not exist,then prints out a success message in the test report.If it actually does exist,then it prints out a failure in the report.
This method is used to verify that the current value of ‘name’property matches the expected value.The property to be checked is the first parameter and the expected value is the second parameter.There are various Properties that you can use for a File control.
The commonly used ones are:
name - The html name attribute of the File control
id - The html id attriute of the File control
label - The label for this File control
suffix - The suffix that is immediately after the Filefield
value - The path of the Filefield
Besides the above properties you could use any of the properties of the MSHtml File object.The properties are enumerated at:msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/input_file.asp If the result is a success then prints a Success to the report.Otherwise prints a failure.
Set the text of this File control to the path name passed as parameter.The path is only set if it is a file that exists on the system.If the path doesn’t exist then the method raised a RuntimeError.
Check to see if the object exists or not at runtime.
Returns true if the object exists, false if it doesn’t
| WET is a opensource automated web testing tool which uses Watir as the library to drive web pages. WET drives an IE Browser directly and so the automated testing done using WET is equivalent to how a user would drive the web pages. WET extends the scripting abilities of Watir and also offers the convenience of recorders. It is licensed under LGPL and BSD style open source licenses. |