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

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introducing JavaScript
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Computer Science A 2: 6/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I Javascript Jongwook Woo,
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
آموزش طراحی وب سایت جلسه دهم – جاوا اسکریپت 1 تدریس طراحی وب برای اطلاعات بیشتر تماس بگیرید تاو شماره تماس: پست الکترونیک :
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
2440: 211 Interactive Web Programming Expressions & Operators.
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.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
CSC Programming for Science Lecture 7: Math Functions.
Keeping it Neat: Functions and JavaScript Source Files Chapter 7.
LOGO Introduction to Client-Side Scripting and JavaScript CHAPTER 9 Eastern Mediterranean University School of Computing and Technology Department of Information.
Javascript. What is JavaScript? Scripting (interpreted) language designed for the web Beware: JavaScript is case sensitive.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
1 JavaScript
05 – Java Script (1) Informatics Department Parahyangan Catholic University.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
1 JavaScript in Context. Server-Side Programming.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Web Development JavaScript. Introduction to JavaScript.
Hazırlayan:Emin BORANDAĞ 2/17/ Numerik Değerler Kullanımı Integers are considered accurate up to 15 digits. Try it function myFunction() { var x.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer,
VB Script V B S.
Introduction to Client-Side Scripting and JavaScript
CHAPTER 10 JAVA SCRIPT.
Overview: Programming Concepts
My First Web Page document.write("" + Date() + ""); To insert.
JavaScript.
Introduction to Client-Side Scripting and JavaScript
T. Jumana Abu Shmais – AOU - Riyadh
CS105 Introduction to Computer Concepts
Introduction to Programming with Python
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

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

2 Day 4 JavaScript Basics

 An object-oriented scripting language used to enable programmatic access to objects within the client application look  Was designed to look like Java  Unrelated to the Java programming language despite the name  Weakly typed  Almost entirely object-based (JavaScript objects are associative arrays) 3

 Originally developed by Brendan Eich of Netscape  Originally name Mocha, which was later renamed to LiveScript, and finally to JavaScript  The language's name is the result of a co- marketing deal between Netscape and Sun, in exchange for Netscape bundling Sun's Java runtime with their (dominant at the time) browser 4

Most popular:  Internet Explorer: ◦ Microsoft Visual Studio ◦ Microsoft Script Editor ◦ Microsoft Script Debugger  Firefox ◦ Firebug ◦ Venkman  Opera ◦ DragonFly  Safari ◦ WebKit's Web Inspector includes a JavaScript debugger 5

 Open Firebug  Click the “Console” tab 6 Click the Firebug icon to open the Firebug add-on

 Click the downward triangle on the Console tab  Select “Enable” 7 Click the downward triangle Select “Enabled”

 You can enter JavaScript commands at the prompt and have the interpreter respond immediately. 8 Enter commands here

 JavaScript variables are used to hold values or expressions.  Variable can have a short or long names  Rules for JavaScript variable names: ◦ Variable names are case sensitive (y and Y are two different variables) ◦ Variable names must begin with a letter or the underscore character  Creating variables in JavaScript is most often referred to as "declaring" variables. 9

 Declare JavaScript variables with the var statement: ◦ var x; var carname;  Assign values to the variables when you declare them:  var x=5; var carname="Volvo"; 10 The variables are empty (they have no values yet)

 If you redeclare a JavaScript variable, it will not lose its original value. var x=5; var x;  If you assign values to variables that have not yet been declared, the variables will automatically be declared. ◦ These statements have the same effect : x=5; var x=5; 11 x is empty

 You can do arithmetic operations with JavaScript variables: x=12;y=x-5;z=y+3; var total = y+z; 12 Operat or DescriptionExampleResult +Additionx=y+2x=7 -Subtractionx=y-2x=3 *Multiplicationx=y*2x=10 /Divisionx=y/2x=2.5 %Modulus (division remainder)x=y%2x=1 ++Incrementx=++yx=6 --Decrementx=--yx=4

 The + operator can also be used to add string variables or text values together. ◦ txt1="What a very"; txt2="nice day"; txt3=txt1+txt2;  After the execution of the statements above, the variable txt3 contains "What a verynice day". 13

To add a space between the two strings, insert a space into one of the strings: ◦ txt1="What a very "; txt2="nice day"; txt3=txt1+txt2; Or insert a space into the expression: ◦ txt1="What a very"; txt2="nice day"; txt3=txt1+" "+txt2; 14

 Conditional statements compare values and take action depending on the result if (age<18) document.write("Too young");  Comparison operators are used in logical statements to determine equality or difference between variables or values. (x=5) 15 OperatorDescriptionExample ==is equal tox==8 is false !=is not equalx!=8 is true >is greater thanx>8 is false <is less thanx<8 is true >=is greater than or equal tox>=8 is false <=is less than or equal tox<=8 is true

 JavaScript also contains a conditional operator that assigns a value to a variable based on some condition. Syntax: variablename=(condition)?value1:value2 Example greeting=(visitor=="PRES")?"Dear President ":"Dear "; If the variable visitor has the value of "PRES", then the variable greeting will be assigned the value "Dear President " else it will be assigned "Dear". 16

 Logical operators are used to determine the logic between variables or values. (x=6 and y=3) 17 OperatorDescriptionExample &&and(x 1) is true ||or(x==5 || y==5) is false !not!(x==y) is true

 Use the if....else statement to execute some code if a condition is true and another code if the condition is not true. Syntax if (condition) { code to be executed if condition is true } else { code to be executed if condition is not true } 18

 If the time is less than 10, you will get a "Good morning" greeting.  Otherwise you will get a "Good day" greeting. var d = new Date(); var time = d.getHours(); if (time < 10) { document.write("Good morning!"); } else { document.write("Good day!"); } 19

 The Math object allows you to perform mathematical tasks.  The Math object includes several mathematical constants and methods. The following example uses the round() method of the Math object to round a number to the nearest integer: Math.round(4.7) The following example uses the floor() and random() methods of the Math object to return a random number between 0 and 10: document.write(Math.floor(Math.random()*11)); 20

21 MethodDescription abs(x)Returns the absolute value of x acos(x)Returns the arccosine of x, in radians asin(x)Returns the arcsine of x, in radians atan(x)Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians atan2(y,x)Returns the arctangent of the quotient of its arguments ceil(x)Returns x, rounded upwards to the nearest integer cos(x)Returns the cosine of x (x is in radians) exp(x)Returns the value of E x floor(x)Returns x, rounded downwards to the nearest integer log(x)Returns the natural logarithm (base E) of x max(x,y,z,...,n)Returns the number with the highest value min(x,y,z,...,n)Returns the number with the lowest value pow(x,y)Returns the value of x to the power of y random()Returns a random number between 0 and 1 round(x)Rounds x to the nearest integer sin(x)Returns the sine of x (x is in radians) sqrt(x)Returns the square root of x tan(x)Returns the tangent of an angle

var chars = ' ABCDEFGHIJKLMNOPQRSTUVWXTZabc defghiklmnopqrstuvwxyz'.split(''); length = Math.floor(Math.random() * chars.length); var str = ''; for (var i = 0; i < length; i++) { str += chars[Math.floor( Math.random() * chars.length)]; } str; 22