Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.

Slides:



Advertisements
Similar presentations
Intro to Javascript CS Client Side Scripting CS380 2.
Advertisements

Molecular Biomedical Informatics Web Programming 1.
Introducing JavaScript
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
Session 8 JavaScript/Jscript: Objects Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
The Web Warrior Guide to Web Design Technologies
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 11 Working with Operators and Expressions
Tutorial 14 Working with Forms and Regular Expressions.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 12 - JavaScript: Objects Outline 12.1 Introduction 12.2 Thinking About Objects 12.3 Math Object.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
CST JavaScript Validating Form Data with JavaScript.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
2 Alerts and the If/Else Conditional Statement CONTINUED There's No Right Way to Do It There are, literally, a million ways to write any given script.
Tutorial 14 Working with Forms and Regular Expressions.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
JavaScript & DOM Client-side scripting. JavaScript JavaScript is a tool to automate client side (which is implemented using HTML so far) JavaSript syntax.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
DOM and JavaScript Aryo Pinandito.
D2L Notes Be sure to submit your link in the dropbox provided on D2L You can just upload an empty text file if a file upload is required Do not use D2L.
1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel,
CITS1231 Web Technologies JavaScript and Document Object Model.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
String Object.  Conundrum: I would like people to have more time on the revisions…  … but I don't have a lot of time myself for more grading  A1 Revision.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
JavaScript For...In Statement The for...in statement loops through the elements of an array or through the properties of an object. Syntax for (variable.
5.2 DOM (Document Object Model). 2 Motto: To write it, it took three months; to conceive it three minutes; to collect the data in it — all my life. —F.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Project 1: Using Arrays and Manipulating Strings Essentials for Design JavaScript Level Two Michael Brooks.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming strings.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
School of Computing and Information Systems CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within.
JavaScript Loops. Looping Want to be able to do things more than once Basic: for (var i=initial; while-clause; increment) { statement; }
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JavaScript: Objects 1 © by Pearson Education, Inc. All Rights Reserved.
Tutorial 11 1 JavaScript Operators and Expressions.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
This is our seminar JavaScript And DOM This is our seminar JavaScript And DOM.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
OVERVIEW OF CLIENT-SIDE SCRIPTING
XML DOM Week 11 Web site:
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
Java Script: Objects (Chapter 12 in [2]). 2 Outline Introduction Introduction Thinking About Objects Thinking About Objects Math Object Math Object String.
JavaScript, Sixth Edition
>> Introduction to JavaScript
Programming Web Pages with JavaScript
>> JavaScript: Document Object Model
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Scripting the DOM MIS 3502, Fall 2016 Jeremy Shafer Department of MIS
CS 371 Web Application Programming
In this session, you will learn about:
JavaScript Objects.
Working with Forms and Regular Expressions
Document Object Model (DOM): Objects and Collections
JavaScript: Objects.
JavaScript: Introduction to Scripting
Exam Prep.
Web Programming and Design
What We Want To Do User enters: Mary Smith
Presentation transcript:

Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel

2 Day 5 Selenium IDE Advanced JavaScript

Loops execute a block of code a specified number of times, or while a specified condition is true  In JavaScript, there are two different kind of loops: ◦ for - loops through a block of code a specified number of times ◦ while - loops through a block of code while a specified condition is true 3

 Used when you know in advance how many times the script should run.  Often used to cycle through lists or arrays Syntax for (var=startvalue;var<=endvalue;var=var+increment) { code to be executed } Example var fruit = "apples,oranges,bananas".split(","); for (i=0;i<fruit.length;i++) { alert("We have many sweet " + fruit[i] + "!"); } 4

 The while loop cycles through a block of code while a specified condition is true.  Used when exact input is unknown Syntax while (var<=endvalue) { code to be executed } Example var name = prompt("What is your name", "Enter your name here"); while (name != "Done") { alert("Very happy to meet you " + name + "!"); var name = prompt("What is your name", "Enter your name here"); } 5

 Used to manipulate a stored piece of text.  The Math object includes several mathematical constants and methods. The following example uses the length property of the String object to find the length of a string: var txt="Hello world!"; document.write(txt.length); The following example uses the toUpperCase() method of the String object to convert a string to uppercase letters: var txt="Hello world!"; document.write(txt.toUpperCase()); 6 12 HELLO WORLD!

MethodDescription indexOf() Returns the position of the first found occurrence of a specified value in a string lastIndexOf() Returns the position of the last found occurrence of a specified value in a string match() Searches for a match between a regular expression and a string, and returns the matches replace() Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring search() Searches for a match between a regular expression and a string, and returns the position of the match slice() Extracts a part of a string and returns a new string split() Splits a string into an array of substrings substr() Extracts the characters from a string, beginning at a specified start position, and through the specified number of character substring() Extracts the characters from a string, between two specified indices toLowerCase() Converts a string to lowercase letters toUpperCase() Converts a string to uppercase letters 7

 Each HTML document loaded into a browser window becomes a Document (DOM) object.  The Document object provides access to all HTML elements in a page, from within a script.  JS HTML DOM can be used to retrieve dynamically assigned ids of elements, during test execution  Complete DOM reference: 8

 getElementById() - Accesses the first element with the specified id getElementById()  document.getElementById()  getElementsByName() - all elements with a specified name getElementsByName()  document.getElementsByName()  getElementsByTagName() - Accesses all elements with a specified tagname getElementsByTagName()  document.getElementsByTagName() 9

DOM AnchorDOM Input Radio DOM AreaDOM Input Reset DOM BaseDOM Input Submit DOM BodyDOM Input Text DOM ButtonDOM Link DOM FormDOM Meta DOM Frame/IFrameDOM Object DOM FramesetDOM Option DOM ImageDOM Select DOM Input ButtonDOM Style DOM Input CheckboxDOM Table DOM Input FileDOM TableCell DOM Input HiddenDOM TableRow DOM Input PasswordDOM Textarea 10

 id - Returns the id of an element id  var x = document.getElementsByTagName(“div”);  var element_id = x[0].id;  nodeType - Returns the type of the element nodeType  var x = document.getElementsByTagName(“input”);  var element_type = x[0].nodeType;  tagName - Returns the tagname of an element as a string (in uppercase) tagName  var x = document.getElementsByName(“firstName”);  var element_tag = x[0].tagName; 11

 hasChildNodes() - Returns whether an element has any child elements hasChildNodes()  var x = document.getElementById(“admin”);  var isParent = x.hasChildNodes();  toString() - Converts an element to a string toString()  var x = document.getElementById(“admin”);  var sub_menues = x.toString();  attributes[] - Returns an array of the attributes of an element attributes[]  var x = document.getElementById(“admin”);  var all_attributes = x.attributes[];  childNodes[] - Returns an array of child nodes for an element childNodes[]  var x = document.getElementById(“admin”);  var sub_menues = x.childNodes[]; 12