?????? ????????? ???? (PHP)

guitarchanceΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 3 μήνες)

529 εμφανίσεις

Міністерство освіти та науки України

Житомирський державний технологічний університет

Факультет інформаційно
-
комп'ютерних технологій






Кафедра ПЗОТ


Група П
І
-
37







Звіт

з виробничої практики












Викона
в
:

Дорошенко Д.А.




Перевіри
ла
:

Яремчук
С.І.







Житомир

2011


2


Зміст

Загальні відомості про підприємство

................................
................................
................................
.............

3

Комп'ютерний парк

................................
................................
................................
................................
..........

4

Роботи, що виконуються із використанням комп’ютерної техніки

................................
............................

5

Мої обов’язки на практиці

................................
................................
................................
..............................

6

Зразок тестового коду

(PHP)

................................
................................
................................
...........................

7

Висновок

................................
................................
................................
................................
.........................

34







3


Загальні відомості про підприємство

Одним із напрямків

діяльності
«ПП Пінчук»

є

створення програмного
забезпечення для
мікроконтролерів
, що використовуються для
автоматиза
ції виробничих процесів.
Наприклад: регулятори температури,
терморегулювання в системах вентиляції та кондиціювання повітря, збір
параметрів повітря (температура, вологість,

рівень вуглекислого газу).
Кон
тролери можуть бути об’єднанні
в мережу
CAN

(
Control

Are
a

Network
)

з виростанням
протоколу
CAN
o
pen



це дозволяє будувати розгалужену
мережу контр
о
лерів (до 1км між пристроями
)
. В мережі може
використовуватись сервер, що працює під управлінням ОС
Linux

та
дозв
оляє управління системою через
веб
інтерфейс.
Кожен контролер
, що
під‘
єднанний
до мережі, може бут
и дистанційно перепрограмований
.

Ще
одним напрямком є програмування для веб
, створення додатків для
соціальних медіа

(
facebook

додатки
)
.




4


Комп'ютерний парк

Вказані технічні характеристики комп’ютерного
парку відображають середні
показники параметрів техніки, що дещо відрізняються одне від одного.

Між собою
комп’ютери пов’язані за допомогою
WiFi

роутера та
Gigabit

Ethernet

мережі (що має
топологію «зірка»), що, в свою чергу, дає доступ до мережі
Internet
.


Ноутбуки (6 шт.):


Apple MacBook Pro

К
оротк
і

технічні
характери
стик
и

Е
кран 17" (1920
x
1200)
LED
, матов
и
й /
Intel

Core

i
7 2.3 ГГц /
RAM

4 ГБ /
HDD

750 ГБ /
Intel

HD

Graphics

/
DVD

Super

Multi

DL

/
Wi
-
Fi

/
Bluetooth

/
веб
-
камера / кардридер
SD

/
Mac

OS

X

10.6.6
Snow

Leopard

Е
кран

17" (1920x1200) WUXGA

Процес
ор

Чотириядерний

Intel Core i7 2.3
ГГц

Об
сяг

оперативно
ї

пам

ят
і

4 ГБ

Тип оперативно
ї

пам

ят
і

DDR3
-
1333

Обсяг ж
ор
стк
ого

диск
у

750 ГБ

Граф
і
ч
н
ий адаптер

В
будовани
й, Intel HD Graphics

Мережеві

адаптер
и

Gigabit LAN

Wi
-
Fi 802.11a/b/g

Bluetooth 2.1 + EDR

Оптич
ний

при
в
і
д

DVD Super Multi

Додаткові
можливості

Веб
-
камера 3 Мп

Р
о
з

є
м
и

та

порт
и

вво
д
у
-
в
и
вод
у

RJ
-
45
LAN


FireWire

800

3
x

USB

2.0

Thunderbolt


Ауд
і
о вх
і
д

Ауд
і
о в
и
х
і
д

ExpressCard
/34

Кардридер
SD

О
С

Mac OS X 10.6 Leopard

Батарея

Лі
т
і
й
-
пол
і
мер, 95 Вт/
год


Десктопи (12 шт.):


К
ороткі технічні
характери
стик
и

AMD

Athlon

II

X
3 425 (2.7
ГГц
) /
RAM

4
ГБ

/
HDD

640
ГБ

/

NVI
D
IA

GeForce

GT
320, 1
ГБ

/
LAN

/
DVD
-
Super
-
Multi

Процес
ор

AMD

Athlon

II

X
3 425 (2.7
ГГц
)

Об
сяг

оперативно
ї

пам

ят
і

4 ГБ

Тип оперативно
ї

пам

ят
і

DDR3

Тип в
і
деокарт
и

та

об
сяг

в
і
део
пам

ят
і

Дискретна
, NVIDIA GeForce GT320, 1
ГБ

Ч
і
псет материнско
ї

плат
и

AMD 880G

Об
сяг

HDD

640 ГБ, 7200
rpm
.

Оптич
ний

при
в
і
д

DVD
-
Super
-
Multi

Порт
и

10 х
USB

2.0, 2
x

PS
/2,
VGA
,
Ethernet

(
RJ
-
45),
Serial

Port
,
DVI
-
D
, 6

ауд
і
о

порт
ів
,
headphone

jack
,
microphone

jack

Слоти розширення

PCI

Express

2.0
x
16, 2 х
PCI

Express

2.0
x
1,
PCI

v
2.3

Ауді
о

High

Definition

(5.1)

5


Роботи, що виконуються
і
з
використанням комп’ютерної техніки

Розробка та тестування програмного забезпечення для мікроконтроллерів,
веб
додатків
, налаштування робочого середовища серверів додатків з використанням
мережі

Інтернет

(
напр.,
Amazon EC2)
, використання різноманітних
інтегрованих
середовищ розробки

(
Eclipse
,
NetBeans
…)
, веб

браузерів (
Mozilla

Firefox
,
Opera
,
Google

Chrome
,
Safari

)
.




Використання пошукової системи
Google
,
прослуховування музики
, онлайн
конференції (
Skype
,
Cisco

WebEx
)

та інше.


6


Мої обов’язки на
практиці

Функціональне тестування веб порталу з використанням фреймворку тестування
Selenium
.

Selenium



це об

єктно
-
орієнтован
а

JavaScript

програма,

що може аналі
зувати
файли певно
ї

структури для того, щоб знаходити в них

команди для маніпуляції

браузером

та команди для виконання певних д
і
й та перев
і
рок
.
Selenium

підтримується
Microsoft Internet Explorer
,
Google Chrome
,
Mozilla Suite

и
Mozilla Firefox

для
Microsoft
Windows
,
Linux
, и
Apple Macint
osh
.

У рамках проекту
Selenium

також випускається інструмент
Selenium

IDE
, що
являє собою версію досить популярної бібліотеки
Selenium

в
GUI

оболонці. Це
реалізовано у вигляді розширення до браузера
Firefox
, розміром приблизно 240 Кб,
включаючи сам
Seleniu
m
. Інструмент дозволяє записувати та
відтворювати скрипти,
що являють собою звичайні
HTML

сторінки з однією таблицею, що містить команди.


Підтримувані платформи:

Microsoft Windows



Firefox 2, 3, 3.x



Internet Explorer 6, 7, 8



Safari 2,3



Opera 8, 9, 10



Google Chrome

Mac OS X



Safari

2, 3, 4



Firefox

2, 3, 3.x



Camino

1.0a1



Mozilla
Suite

1.6+, 1.7+



Seamonkey

1.0

GNU/Linux



Firefox

2
, 3, 3.x



Mozilla Suite

1.6+, 1.7+



Konqueror



Opera

8, 9, 10

Інші браузери


часткова підтримка залежно від ОС, браузера та налаштувань безпеки
браузера.

Для використання
Selenium

розроблені бібліотеки для
PHP
,
C
#,
Ruby
,
Java
,
Perl
,
Python

та ін.

На практиці я використовував можливість програмування тестів на мові
PHP.



7


Зразок

тестового коду

(
PHP
)


<?php


if(!in_array('SeleniumBase', get_declared_classes()))

{


require_once __DIR__.'/../../library/SeleniumBase.php';

}

if(!in_array('loginTests',

get_declared_classes()))

{


require_once __DIR__.'/../login/login.php';

}


class clientsActionsTests extends SeleniumBase{



//
------------------------------------------------------------------------------





var $addUserButton = "//*[
@id='admin_account_content']/form/button[text()='Add']"; // add button




var $saveUserButton = "//*[@id='admin_account_content']/form/button[text()='Save']"; // save button




var $createUserFormElements = array(




"username" => 'id=username', // username text input


"email" => 'id=email', // email text input


"role" => 'id=role', // role select input




'admin' =
> "//*[@id='role']/option[text()='Administrator']", // role select option


'user' => "//*[@id='role']/option[text()='User']", // role select option




"fbID" => 'id=facebook_id',

// FB ID text input


"pass" => 'id=new_password', // new pass text input


"passConfirm" => 'id=new_password_confirmation', // new pass confirmation text input




'brands'

=> "//*[@id='admin_account_content']/form/table/tbody/tr[8]/td/div/div[3]/span/div/input", // brands
text input


'geo' => "//*[@id='admin_account_content']/form/table/tbody/tr[9]/td/div/div[3]/span/div/input", // geotarge
t-
ing text inp
ut




'cancel' => "//*[@id='admin_account_content']/form/a[text()='Cancel']" // cancel link




);






var $createUserErrors = array(




'emptyName' =>

"Value is required and can't be empty"






);



//
------------------------------------------------------------------------------





var $saveBrandBtnLocator = "//*[@id='admin_account_content']/form/button[text()='Save']"; // 'Save' button for
editing


var $addBrandBtnLocator = "//*[@id='admin_account_content']/form/button[text()='Add']"; // 'Add' button for cre
a-
tion





var $createBrandFormElements = array(




'siteURL' => "id=url", // Site URL text input


'fbPageId' => "id=facebook_name", // Facebook Page ID text input


'twitterId' => "id=
twitter_id", // Twitter ID text input


'youtubeId' => "id=youtube_id", // Youtube ID text input




'pubAppName' => "id=publisher_name", // Publisher App Name text input

8



'pubCheckBox' =>

"name=publisher", // Publisher checkbox




'cancel' => "//*[@id='admin_account_content']/form/a[text()='Cancel']" // 'Cancel' button




);




// these links appear when the 'Publi
sher' checkbox is checked




var $giveRights = "//*[@id='admin_account_content']/a[1][text()='Give rights']";




var $skipGivingRights = "//*[@id='admin_account_content']/a[2][text()='Skip']";



//============================================
==================================




function setUp() {


$this
-
>setBrowser(BROWSER);


$this
-
>setBrowserUrl(BASE_URL);


}



//==============================================================================


/*


function testClientCreation(){


$login = new loginTests();


$login
-
>getLoggedIn(&$this);




$clientName = SeleniumBase::_getRandStr();




$this
-
>_addClient(&$this, $clientName );


SeleniumBase::_waitForT
ext(&$this, $clientName);




$this
-
>_deleteClient(&$this, $clientName, TRUE);




$this
-
>_addClient(&$this, $clientName, NULL, TRUE);


SeleniumBase::_waitForTextNot(&$this, $clientName, 5);


}




function
testClientsCreation(){


$login = new loginTests();


$login
-
>getLoggedIn(&$this);




$clients = array();


for($i = 0; $i < 3; $i++){


$clients[$i]['name'] = SeleniumBase::_getRandStr();


$
clients[$i]['logo'] = NULL;


}


$this
-
>_addClients(&$this, $clients);


}




function testDeleteClient(){


$login = new loginTests();


$login
-
>getLoggedIn(&$this);




// test deleting




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient(&$this, $clientName);


sleep(2);


$this
-
>_deleteClient(&$this, $clientName, TRUE);




// test cancelling deleting




$this
-
>_addClient(&$
this, $clientName);


sleep(2);


$this
-
>_deleteClient(&$this, $clientName, FALSE);


sleep(2);


$this
-
>_deleteClient(&$this, $clientName, TRUE);

9



}




function testEditClient()


{


$login = new loginTests();


$login
-
>getLoggedIn(&$this);




// add client for this test




$oldName = SeleniumBase::_getRandStr();


$this
-
>_addClient(&$this, $oldName);




// click on edit link, and then on cancel link




$this
-
>_editClient(&$this, $oldName, SeleniumBase::_getRandStr(), NULL, FALSE);


SeleniumBase::_waitForText(&$this, 'Clients');


SeleniumBase::_waitForText(&$this
, $oldName);




// click on edit link, and then change client's name




$newName = SeleniumBase::_getRandStr();


$this
-
>_editClient(&$this, $oldName, $newName, NULL);


SeleniumBase::_waitForText(&$t
his, 'Clients');


SeleniumBase::_waitForText(&$this, $newName);




// trying to type empty string as client's new name




$this
-
>_editClient(&$this, $newName, '', NULL);


SeleniumBase::_waitForText(&$this,"
Value is required and can't be empty");


SeleniumBase::_waitForText(&$this,"Name");


SeleniumBase::_waitForText(&$this,"Logo");


$this
-
>type("id=name", $newName);


SeleniumBase::_waitForText(&$this, 'Clients');


SeleniumB
ase::_waitForText(&$this, $newName);




// delete client for this test


$this
-
>_deleteClient(&$this, $newName);




}


*/




//
--------------------------------------------------------------------------




/*


function testUserCreation()


{


$login = new loginTests;


$login
-
>getLoggedIn($this);


sleep(2);




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);





$this
-
>_getUsersTab($this, $clientName);




$this
-
>_userCreationFormTest($this);



// $user = SeleniumBase::_getRandUser();

// $this
-
>_addNewUser($this, $user);

// //sleep(3);

// $this
-
>_
removeUser($this, $user['name'],TRUE);

// $this
-
>_getUsersTab($this, $clientName);

// $this
-
>_removeUser($this, $user['name']);




$this
-
>_deleteClient($this, $clientName);



10



}




function testUserEdit()


{


$login = new loginTests;


$login
-
>getLoggedIn($this);


sleep(1);




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);


$this
-
>_getUsersTab($this, $clientName);




$user = SeleniumBase::_getRandUser();


$this
-
>_addNewUser($this, $user);


$user2 = SeleniumBase::_getRandUser();


$this
-
>_editUser($this, $user['name'], $user2);


$user = SeleniumBase::_getRandUser();


$t
his
-
>_editUser($this, $user2['name'], $user, TRUE);




$this
-
>_removeUser($this, $user2['name']);


$this
-
>_deleteClient($this, $clientName);


}




function testUserDelete()


{


$login = new loginTests;


$login
-
>getLoggedIn($this);


sleep(1);




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);


$this
-
>_getUsersTab($this, $clientName);




$user = SeleniumBase::_getRandUser();


$this
-
>_addNewUser($this, $user);




$this
-
>_removeUser($this, $user['name']);


$this
-
>_deleteClient($this, $clientName);


}




function testUserCreationForm()


{



$login = new loginTests;


$login
-
>getLoggedIn($this);


sleep(1);




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);


$this
-
>_getUsersTab($this, $clientName);





$this
-
>_userCreationFormTest($this);




$this
-
>_deleteClient($this, $clientName);


}


*/




//
--------------------------------------------------------------------------




function testBrandCreation()


{


FacebookActions::loginToFacebook($this, FB_MY_LOGIN, FB_MY_PASS);




$login = new loginTests;


$login
-
>getLoggedIn(&$this);




$path = "link=account";

11



$this
-
>click($path);


SeleniumBase::_waitForText(&$this,'Add New Client');




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);




$this
-
>_getBrandsTab($this, $clientName);




//$b
rand1 = SeleniumBase::_getBrand();


//$brandName1 = $this
-
>_addNewBrand($this, $brand1);




$brand2 = SeleniumBase::_getRandBrand();


$brandName2 = $this
-
>_addNewBrand($this, $brand2);




$b
rand3 = SeleniumBase::_getRandBrand();


$brandName3 = $this
-
>_addNewBrand($this, $brand3, FALSE);




$brand4 = SeleniumBase::_getRandBrand();


$brandName4 = $this
-
>_addNewBrand($this, $brand4, TRUE, TRUE);


$this
-
>assertTrue(NULL === $brandName4);




$brand5 = SeleniumBase::_getRandBrand();


$brandName5 = $this
-
>_addNewBrand($this, $brand5, FALSE, TRUE);


$this
-
>assertTrue(NULL === $brandName5);






for($i = 0; $i <

3; $i++){


$tmpBrand = SeleniumBase::_getRandBrand();


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);


$this
-
>_removeBrand($this, $tmpBrandName);


}






//$this
-
>_removeBrand($this, $br
andName1);


$this
-
>_removeBrand($this, $brandName3);


$this
-
>_removeBrand($this, $brandName2);




$this
-
>_deleteClient($this, $clientName);


}




function testEditBrand()


{


FacebookActions::loginToFacebook($this, FB_MY_LOGIN, FB_MY_PASS);




$login = new loginTests;


$login
-
>getLoggedIn(&$this);




$path = "link=account";


$this
-
>click($path);


SeleniumBase::_waitForText(&$this,'Add New Client');




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);




$this
-
>_getBrandsTab($this, $clientName);




//fo
r($j =0; $j < 3; $j++){




// + +


{


$tmpBrand = SeleniumBase::_getRandBrand();


$tmpBrand['appName'] = 'some app name';


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);





$newBrand = SeleniumBase::_getRandBrand();


$newBrand['appName'] = 'new app name';

12



$newBrand['fbPageId']=$tmpBrand['fbPageId'];




sleep(1);


$this
-
>_editBrand($this, $tmpBrandName, $newBrand);



sleep(1);


$this
-
>_removeBrand($this, $tmpBrandName);




}


sleep(3);






// +
-


{


$tmpBrand = SeleniumBase::_getRandBrand();


$tmpBrand['appName'] = 'some app name';


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);




$newBrand = SeleniumBase::_getRandBrand();


unset($newBrand['appName']);


$newBrand['fbPageId']=$tmpBrand['fbPageId'];


sleep(1);


$this
-
>_editBrand($this, $tmpBrandName, $newBrand);


sleep(1);


$this
-
>_removeBrand($this, $tmpBrandName);




}


sleep
(3);






// bug: brand created with publisher, edited without publisher


// but the system asks for giving rights to our platform app


//
-

+


{


$tmpBrand = SeleniumBase::_getRandBrand();



unset($tmpBrand['appName']);


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);




$newBrand = SeleniumBase::_getRandBrand();


$newBrand['appName'] = 'new app name';


$newBrand['fbPageId']=$
tmpBrand['fbPageId'];


sleep(1);


$this
-
>_editBrand($this, $tmpBrandName, $newBrand);


sleep(1);


$this
-
>_removeBrand($this, $tmpBrandName);




}


sleep(3);






// bug: brand created without publisher, edited without publisher


// but the system asks for giving rights to our platform app


//
-

-


{


$tmpBrand = SeleniumBase::_getRandBrand();


unset($tmpBrand['appN
ame']);


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);




$newBrand = SeleniumBase::_getRandBrand();


unset($newBrand['appName']);


$newBrand['fbPageId']=$tmpBrand['fbPageId'];


sleep(1);


$this
-
>_editBrand($this, $tmpBrandName, $newBrand);


sleep(1);


$this
-
>_removeBrand($this, $tmpBrandName);




}

13



sleep(3);


//}




for($i = 0; $i < 3; $i+
+){


$tmpBrand = SeleniumBase::_getRandBrand();


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);




$newBrand = SeleniumBase::_getRandBrand();


$newBrand['fbPageId']=$tmpBrand['fbPageId'];


sleep(3);


$this
-
>_editBrand($this, $tmpBrandName, $newBrand);


sleep(1);


$this
-
>_removeBrand($this, $tmpBrandName);


sleep(3);


}




$this
-
>_deleteClient($this, $cli
entName);


}




function testAddBrandForm()


{


FacebookActions::loginToFacebook($this, FB_MY_LOGIN, FB_MY_PASS);




$login = new loginTests;


$login
-
>getLoggedIn(&$this);




$path = "link
=account";


$this
-
>click($path);


SeleniumBase::_waitForText(&$this,'Add New Client');




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);




$this
-
>
_getBrandsTab($this, $clientName);




$this
-
>_addBrandFormTesting($this, $clientName);




$this
-
>_deleteClient($this, $clientName);




}






function testBrandDelete()


{


FacebookActions::loginToFacebook($this, FB_MY_LOGIN, FB_MY_PASS);




$login = new loginTests;


$login
-
>getLoggedIn(&$this);




$path = "link=account";


$this
-
>click($path);


SeleniumBas
e::_waitForText(&$this,'Add New Client');




$clientName = SeleniumBase::_getRandStr();


$this
-
>_addClient($this, $clientName);




$this
-
>_getBrandsTab($this, $clientName);




$createdBrandNames = ar
ray();




for($i = 0; $i < 5; $i++){




$tmpBrand = SeleniumBase::_getRandBrand();


sleep(1);


$tmpBrandName = $this
-
>_addNewBrand($this, $tmpBrand);


array_push(&
$createdBrandNames, $tmpBrandName);

14



}




foreach ($createdBrandNames as $name){


$this
-
>_removeBrand($this, $name);


sleep(1);


}




$this
-
>_deleteClient($this, $clientName);




}




//==============================================================================




function _addClient($browser, $clientName, $clientLogo = NULL, $cancel = FALSE){




$this
-
>_createClient(&
$browser, $clientName, $clientLogo, $cancel);


if($cancel !== TRUE){


SeleniumBase::_waitForText(&$browser, $clientName, DELAY);


}


SeleniumBase::_waitForText(&$browser, 'Clients', DELAY);


}




/* clientsInfo:


*


* array(


* integer => array(




* * 'name' => clientName,


* 'logo' => clientLogo


* )


* )


*/


function _addClients($browser, array $clientsInfo){




foreach($clientsInfo as $key => $client){




$this
-
>_createClient(&$browser, $client['name'], $client['logo']);


SeleniumBase::_waitForText(&$
browser, $client['name'], DELAY);




}


}




/*


* $cancel === FALSE
-
> cancel client cretion routine


* otherwise
-
> create client


*/


function _createClient($bro
wser, $clientName, $clientLogo = NULL, $cancel = FALSE){




$browser
-
>click('link=account');


SeleniumBase::_waitForElement(&$browser, 'link=Add New Client');


//sleep(1);


$browser
-
>click('link=Add New Clien
t');




SeleniumBase::_waitForElement(&$browser,"//*[@id='name']");


SeleniumBase::_waitForElement(&$browser,"//*[@id='admin_account_content']/form/button");


SeleniumBase::_waitForElement(&
$browser,"//*[@id='admin_account_content']/form/a[text()='Cancel']");






//type client's name


$browser
-
>type("//*[@id='name']",$clientName);




if(FALSE === $cancel){




//click the add button


$browser
-
>click("//*[@id='admin_account_content']/form/button");



15



//echo 'add client clicked';




}else{




//click the cancel button



$browser
-
>click("//*[@id='admin_account_content']/form/a[text()='Cancel']");




//echo 'cancel add client clicked';


}




}




/**


*


* $toDelete == TRUE
-
> we are about to test deleting clie
nt


* FALSE
-
> cancelling deleting client


*


* @param type $browser
-

logged in browser


*/


function _deleteClient(&$browser, $clientName, $toDelete = TRUE){




$browser
-
>
click('link=account');


SeleniumBase::_waitForText(&$browser, 'Clients');


SeleniumBase::_waitForText(&$browser, $clientName);




if(TRUE === $toDelete){




//path to remove link in the same

row with client with name = $clientName


$path="//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$clientName']/../../a[text()='remove
']";


$browser
-
>click($path);





//path to the appeared 'Do you want remove?' link


$path="//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$clientName']/../../span[2]/a[2][text
()='Do you want remove?']";


SeleniumBase::_waitFor
Element(&$browser,$path);


$browser
-
>click($path);


sleep(1);


SeleniumBase::_waitForText(&$browser,'Clients');


SeleniumBase::_waitForTextNot(&$browser,$clientName,5);




}else{




//path to remove link in the same row with client with name = $clientName


$path="//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$clientName']/../../a[text()='remove
']";


SeleniumBas
e::_waitForElement(&$browser, $path);


$browser
-
>click($path);



//path to the appeared 'Do you want remove?' link


$path="//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$clientName']/../../span[2]/a[2][text
()='Do you want remove?']";


SeleniumBase::_waitForElement(&$browser,$path);



//path to the appear
ed 'cancel' link


$path="//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$clientName']/../../span[2]/a[1][text
()='cancel']";


SeleniumBase::_waitForElement(&$browser,$path);


$browser
-
>click($path);



//path to new position of 'remove' link

16



$path =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$clientName']/../../span[2]/a[text()='remov
e']";


SeleniumBase::_waitForEleme
nt(&$browser,$path);




}


}




/*


* $toEdit == TRUE
-
> we are about to edit the info


* FALSE
-
> cancel editing


*/


function _editClient(&$browser, $clientName, $new
Name, $newLogo, $toEdit = TRUE)


{




$browser
-
>click('link=account');


SeleniumBase::_waitForText(&$browser, 'Clients');


SeleniumBase::_waitForText(&$browser, $clientName);


// path to

edit link associated with $clientName


$path =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span/b[text()='$clientName']/../../a[2][text()='edit']";


$browser
-
>click($path);


SeleniumBase::_waitForText(&
$browser, 'Name');


SeleniumBase::_waitForText(&$browser, 'Logo');


SeleniumBase::_waitForText(&$browser, 'Save');



// locator to name input field


$path = "id=name";


$browser
-
>type($path,$newName);


sleep(1);


if(TRUE === $toEdit){



// save button's locator


$path = "//*[@id='admin_account_content']/form/button[text()='Save']";


$browser
-
>click($path);




}else{





// cancel button's locator


$path = "//*[@id='admin_account_content']/form/a[text()='Cancel']";


$browser
-
>click($path);




}


}





//===================
===========================================================




/**


* @param $browser
-

browser with already opened 'Users' tab for some client


*/


function _removeUser(&$browser, $username, $cancel = FALSE)


{


// path to remove link for user


$path =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span/b[text()='$username']/../../a[1][text()='remove']";


SeleniumBase::_waitForElement(&$browser, $path);


$browser
-
>click(
$path);




if(FALSE === $cancel){




// path to 'Do you want remove?' link


$path2="//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$username']/../../span[2]/a[2][text
()='Do you
want remove?']";


SeleniumBase::_waitForElement(&$browser, $path2);

17



$browser
-
>click($path2);


SeleniumBase::_waitForTextNot(&$browser,$username,5);




}else{




// path to 'cancel' l
ink


$path2 =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$username']/../../span[2]/a[1][text()='canc
el']";


SeleniumBase::_waitForElement(&$browser,$path2);


$browser
-
>click($path2);



SeleniumBase::_waitForText(&$browser,$username);


SeleniumBase::_waitForTextNot(&$browser,'cancel');




// path to new position of 'remove' link


$path3 =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$username']/../../span[2]/a[1][text()='remo
ve']";


SeleniumBase::_waitForElement(&$browser,$path3);




}



}




/**


*


* @param type $browser
-

browser with the list of users opened in it


* @param array $user


* @param type $uBrandAccess


* @param type $uPublisherGeotargeting


* @param type $confPass


*/


protected function _userCreationFormTest(&$browser)


{


//
--------------

illegal names




$user=SeleniumBase::_getRandUser();


$user['name']='';


$this
-
>_addNewUser($
browser, $user);


SeleniumBase::_waitForText($browser, $this
-
>createUserErrors['emptyName']);


$this
-
>_reopenUsersTab($browser);








$user=SeleniumBase::_getRandUser();


$user['name']='

';


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser, $this
-
>createUserErrors['emptyName']);


$this
-
>_reopenUsersTab($browser);






// bug with username: nothing is checked




$user=SeleniumBase::_getRandUser();


$user['name']='~!@#$%^&*()_+_)(*&^%$#@!!@#@#';


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser, $user['name']);


$this
-
>_removeUser($browser, $use
r['name']);






//
----

trying to reuse the name




$user=SeleniumBase::_getRandUser();


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser, $user['name']);




$this
-
>
_addNewUser($browser, $user);

18



SeleniumBase::_waitForText($browser,'User with such username already exists. Try another please');


SeleniumBase::_waitForText($browser,'User with such email already exists. Try another please');


$this
-
>
_reopenUsersTab($browser);


$this
-
>_removeUser($browser, $user['name']);






//
-------------

illegal emails






$user=SeleniumBase::_getRandUser();


$this
-
>_addNewUser($browser, $use
r);


SeleniumBase::_waitForText($browser, $user['name']);


$tmp = $user['name'];


$user['name']= SeleniumBase::_getRandStr();


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'User with such email already exists. Try another please');


$this
-
>_reopenUsersTab($browser);


$this
-
>_removeUser($browser, $tmp);








$user=SeleniumBase::_getRandUse
r();


$user['email']=SeleniumBase::_getRandStr();


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is no valid email address in the basic format local
-
part@hostname');


$this
-
>_reopenUsersTab($browser)
;








$user=SeleniumBase::_getRandUser();


$user['email']=SeleniumBase::_getRandStr(5).'.'.SeleniumBase::_getRandStr(5);


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is no v
alid email address in the basic format local
-
part@hostname');


$this
-
>_reopenUsersTab($browser);








$user=SeleniumBase::_getRandUser();


$user['email']=SeleniumBase::_getRandStr(5).'@'.SeleniumBase::_getRandStr(5);


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is no valid hostname for email address');


SeleniumBase::_waitForText($br
owser,'does not match the expected structure for a DNS hostname');


SeleniumBase::_waitForText($browser,'appears to be a local network name but local network names are not a
l-
lowed');


$this
-
>_reopenUsersTab($browser);








$user=SeleniumBase::_getRandUser();


$u
s-
er['email']=SeleniumBase::_getRandStr(5).'.'.SeleniumBase::_getRandStr(3).'@'.SeleniumBase::_getRandStr(5);


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitFor
Text($browser,'is no valid hostname for email address');


SeleniumBase::_waitForText($browser,'does not match the expected structure for a DNS hostname');


SeleniumBase::_waitForText($browser,'appears to be a local network name but local netw
ork names are not a
l-
lowed');


$this
-
>_reopenUsersTab($browser);








$user=SeleniumBase::_getRandUser();


$u
s-
er['email']=SeleniumBase::_getRandStr(5).'.'.SeleniumBase::_getRandStr(3).'@'.SeleniumBase::_ge
tRandStr(3).'.'.Sel
eniumBase::_getRandStr(4);


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is no valid hostname for email address');

19



SeleniumBase::_waitForText($browser,'appears to be a DNS hostname but
cannot match TLD against known
list');


SeleniumBase::_waitForText($browser,'appears to be a local network name but local network names are not a
l-
lowed');


$this
-
>_reopenUsersTab($browser);








$user=Sel
eniumBase::_getRandUser();


$user['email']="~!@#$%^&*()_+)(*&^%$#@!~!@#$%^&^%$#WQEFGH%Y%#";


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is no valid hostname for email address');


SeleniumBase::_waitForText($browser,'does not match the expected structure for a DNS hostname');


SeleniumBase::_waitForText($browser,'does not appear to be a valid local network name');


SeleniumBase::_waitForText($browser,'can not b
e matched against dot
-
atom format');


SeleniumBase::_waitForText($browser,'can not be matched against quoted
-
string format');


SeleniumBase::_waitForText($browser,'is no valid local part for email address');


$this
-
>_re
openUsersTab($browser);










$user=SeleniumBase::_getRandUser();


$u
s-
er['email']=SeleniumBase::_getRandStr(5).'@'.SeleniumBase::_getRandStr(5).'@'.SeleniumBase::_getRandStr(5);


$this
-
>
_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is no valid hostname for email address');


SeleniumBase::_waitForText($browser,'does not match the expected structure for a DNS hostname');


SeleniumBase::_waitForText
($browser,'appears to be a local network name but local network names are not a
l-
lowed');


SeleniumBase::_waitForText($browser,'can not be matched against dot
-
atom format');


SeleniumBase::_waitForText($browser,'can not be matched against quot
ed
-
string format');


SeleniumBase::_waitForText($browser,'is no valid local part for email address');


$this
-
>_reopenUsersTab($browser);






//
------------------

illegal fb id






$user=Selenium
Base::_getRandUser();


$user['fbId']=SeleniumBase::_getRandStr();


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'Invalid Facebook user ID. Please try again');


$this
-
>_reopenUsersTab($browser);






$user=SeleniumBase::_getRandUser();


$user['fbId']=SeleniumBase::_getRandHexNumStr();


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'Invalid Facebook user ID. Please try aga
in');


$this
-
>_reopenUsersTab($browser);








//
--------------------

illegal passwords




// bug: the system doesn't require the password to create new user!!!


$user=Selenium
Base::_getRandUser();


$user['password']='';


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser, $user['name']);


$this
-
>_removeUser($browser, $user['name']);






// same passwords t
esting



20



for($i=1;$i<8;$i++){




$user=SeleniumBase::_getRandUser();


$pass = SeleniumBase::_getRandStr($i);


$user['password']=$pass;


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is less than 8 characters long');


$this
-
>_reopenUsersTab($browser);






$user=SeleniumBase::_getRandUser();


$pass = SeleniumBase::_getRandStr($i+16);


$user['password']=$pass;


$this
-
>_addNewUser($browser, $user);


SeleniumBase::_waitForText($browser,'is more than 16 characters long');


$this
-
>_reopenUsersTab($browser);



}






//

bug allowing 'password' input to be empty and 'password confirm' input not to be empty




$user=SeleniumBase::_getRandUser();


$user['password']='';


$this
-
>_addNewUser($browser, $user, NULL,NULL);


SeleniumBase::_waitFo
rText($browser, $user['name']);


$this
-
>_removeUser($browser, $user['name']);




// different passwords of the same length




$user=SeleniumBase::_getRandUser();


$user['password'] = SeleniumBase::_getRandStr(10);


$user['passwordConf'] = SeleniumBase::_getRandStr(10);


$this
-
>_addNewUser($browser, $user, NULL,NULL);


SeleniumBase::_waitForText($browser,'The new password and confirmation does not match');


$this
-
>
_reopenUsersTab($browser);




// different passwords of defferent length




$user=SeleniumBase::_getRandUser();


$user['password'] = SeleniumBase::_getRandStr(10);


$user['passwordConf'] = SeleniumBase::_getRandStr
(12);


$this
-
>_addNewUser($browser, $user, NULL,NULL);


SeleniumBase::_waitForText($browser,'The new password and confirmation does not match');


$this
-
>_reopenUsersTab($browser);



}




/**


*


* @param type $browser
-

browser with 'Add new user' form opened in it


*/


protected function _reopenUsersTab($browser)


{


// path to 'Users' link


$pathUsers="//*[@id='admin_account_content']/form/div/span/a[1]/span[text()='
Users']";


$browser
-
>click($pathUsers);




// path to link for adding new user


$path="//*[@id='admin_account_content']/div/span/a[1]/span[text()='Add new user']";


SeleniumBase::_waitForElement($browser, $path);





}




/*


* $browser
-

browser with already opened 'Add new user' tab

21



*/


protected function _enterUserCreationInfo(&$browser,array $user)


{


// username input locator


$path= $this
-
>createUserFormElements['username'];


$browser
-
>type($path, $user['name']);




// email input locator


$path = $this
-
>createUserFormElements['email'];


$browser
-
>type($path, $user['email']);




// role


// path to drop down


$path=$this
-
>createUserFormElements['role'];


switch ($user['role']) {


case 'User':


$browser
-
>select($path,$user['role']);


break;


case 'Adm
inistrator':


$browser
-
>select($path,$user['role']);


break;


default:


break;


}




// facebook id locator


$path = $this
-
>
createUserFormElements['fbID'];


$browser
-
>type($path, $user['fbId']);




// new pass locator


$path = $this
-
>createUserFormElements['pass'];


$browser
-
>type($path,$user['password']);




// new pass confirmation locator


$path = $this
-
>createUserFormElements['passConfirm'];


$browser
-
>type($path,$user['passwordConf']);








// brand access and permision stuff





if((isset($user['uBrandAccess'])) && (count($user['uBrandAccess']) > 0)){




// path to text input


$path = $this
-
>createUserFormElements['brands'];



// path to unordered list with possible brands



$path2="/html/body/div/div[2]/div[3]/div[2]/div/form/table/tbody/tr[10]/td/div/div[3]/span/div/div/div/ul";



$browser
-
>click($path);


SeleniumBase::_waitForElement(&$browser, $path2);




foreach(
$user['uBrandAccess'] as $uBrand){




// path to list item with appropriate text


$path3="//*[@id='admin_account_content']/form/table/tbody/tr[8]/td/div/div[3]/span/div/div/div/ul/li[text()='$uBrand']";




if($browser
-
>isElementPresent($path3)){


$browser
-
>click($path3) ;


sleep(1);


}




}





}

22





// publisher geotargeting stuff




if((isset($user['$uPublisherGeotargeting'])) && (count($user['$uPublisherGeotargeting']) > 0)){




// path to publisher geotargeting text input


$path = $this
-
>createUserFormElements['geo'];




// path to hidden div


$path2="/html/body/div/div[2]/div[3]/div[2]/div/form/table/tbody/tr[9]/td/div/div[
3]/span/div/div";




// path to ul


$path3="/html/body/div/div[2]/div[3]/div[2]/div/form/table/tbody/tr[9]/td/div/div[3]/span/div/div/div/ul";






foreach($user['$uPublisherGeot
argeting'] as $geoItem){


$browser
-
>type($path,'');


sleep(1);


$browser
-
>type($path,$geoItem);


sleep(1);


try{


SeleniumBase::_waitForElementBecomesVisible(&
$browser,$path3);




// path to list item with appropriate text in it


$path4="/html/body/div/div[2]/div[3]/div[2]/div/form/table/tbody/tr[9]/td/div/div[3]/span/div/div/div/ul/li[contains(.,'$geoI
te
m
')]";




if($browser
-
>isElementPresent($path4)){




$browser
-
>click($path4);


sleep(1);


}





}catch(Exception $ex){




}


}


}


}




/*


* $browser
-
> logged
-
in browser


*/


function _getUsersTab(&$br
owser, $clientName)


{


// path to link for watching users of $clientName client


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b[text()='$clientName']/../../../d
iv[2]/a[1][text
()='show admins']";


SeleniumBase::_waitForElement(&$browser,$path);


$browser
-
>click($path);






// path to link for adding new user


$path="//*[@id='admin_account_content']/div/span/a[1]/span[text()='Add new user']";


SeleniumBase::_waitForElement(&$browser,$path);


}




function _addNewUser(&$browser, array $user)


{





// path to link for adding new user


$path="//*[@id='admin_account_content']/div/span/a[1]/span[text()='Add new user']";


SeleniumBase::_waitForElement($browser, $path);


$browser
-
>click($path);

23





foreach(
$this
-
>createUserFormElements as $item){


SeleniumBase::_waitForElement($browser, $item);


}


SeleniumBase::_waitForElement($browser, $this
-
>addUserButton);




$this
-
>_enterUserCreationInfo($browser, $user);


s
leep(1);


$browser
-
>click($this
-
>addUserButton);




}




/**


*


* @param type $browser
-

browser with opened 'users' tab for some client


* @param string $username
-

name of user to be edited


* @param boolean $cancel
-

cancel editing or save it


*/


function _editUser(&$browser, $userName, $editedUser, $cancel = FALSE)


{


// path to the 'edit' link for user


$editUserBtn =
"//*[@id='admin_account_content']/table/t
body/tr/td[2]/div[1]/span/b[text()='$userName']/../../a[2][text()='edit']";


SeleniumBase::_waitForElement($browser, $editUserBtn);


$browser
-
>click($editUserBtn);




foreach($this
-
>createUserFormElements as $item){


SeleniumBase::_waitForElement($browser, $item);


}


SeleniumBase::_waitForElement($browser, $this
-
>saveUserButton);




$this
-
>_enterUserCreationInfo($browser, $editedUser);


sleep(1);




if($cancel === FALSE){


$browser
-
>click($this
-
>saveUserButton);


SeleniumBase::_waitForText($browser, $editedUser['name']);


}else{


$browser
-
>click($this
-
>createUserFormElements['cancel']);


Selen
iumBase::_waitForText($browser, $userName);


}


}



//==============================================================================




/**


*


* @param type $browser
-

browser with opened list of clients in it


* @param type $clientName


*/


function _getBrandsTab($browser, $clientName)


{


// path to link for watching brands of $clientName client



$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b[text()='$clientName']/../../../div[2]/a[2][text
()='show brands']";


SeleniumBase::_waitForElement(&$browser,$path);


$browser
-
>click($path);



// pa
th to link for adding new brand


$path="//*[@id='admin_account_content']/div/span/a[1]/span[text()='Add new Brand']";


SeleniumBase::_waitForElement($browser, $path);



}



/**

24



*


* @param type $browser
-

browser with opened 'B
rands' tab for some client


* @param type $brand
-

a brand (info) to be added


* @return type
-

title of the created brand, NULL otherwise


*/


function _addNewBrand($browser, $brand, $giveRights = TRUE, $cancelBrandCreation = FALSE)


{


// path to 'Add new Brand' link


$path = "//*[@id='admin_account_content']/div/span/a[1]/span[text()='Add new Brand']";


SeleniumBase::_waitForElement($browser, $path);


$browser
-
>click($path);





foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);






$this
-
>
_typeBrandData($browser, $brand);


sleep(1);




if(FALSE === $cancelBrandCreation){




$browser
-
>click($this
-
>addBrandBtnLocator);




if(isset($brand['appName'])){





if(TRUE === $giveRights){


SeleniumBase::_waitForElement($browser, $this
-
>giveRights);


sleep(1);


$browser
-
>click($this
-
>giveRights);



}else{


S
eleniumBase::_waitForElement($browser, $this
-
>skipGivingRights);


sleep(1);


$browser
-
>click($this
-
>skipGivingRights);


}


}


sleep(1);



// element to wait


switch ($brand['fbPageId']) {



case FB_MY_PAGE_ID:


$createdBrandName = FB_MY_PAGE_NAME;


break;



default:


$createdBrandNam
e = 'DEV
-
';


break;


}


$elementToWait =
"//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b[contains(.,'$createdBrandName')]";


SeleniumBase::_waitForElement($browser, $elementToWait)
;




// path to the created brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


sleep(1);


$title = $browser
-
>
getText($path);



return $title;




}else{

25





$browser
-
>click($this
-
>createBrandFormElements['cancel']);


SeleniumBase::_waitForText($browser,'Add New Brand');


return NULL;




}






}



/**


*


* @param type $browser
-

browser with opened 'Add new brand' form


* @param type $brand


*/


function _typeBrandData($browser,$brand)


{


$browser
-
>type($this
-
>create
BrandFormElements['siteURL'],$brand['siteURL']);






$browser
-
>type($this
-
>createBrandFormElements['fbPageId'],$brand['fbPageId']);






$browser
-
>type($this
-
>createBrandFormElements['twitterId'],$brand['twitterId
']);


$browser
-
>type($this
-
>createBrandFormElements['youtubeId'],$brand['youtubeId']);


if(isset ($brand['appName']))


{


if(!$browser
-
>isChecked($this
-
>createBrandFormElements['pubCheckBox'])){


$brow
ser
-
>click($this
-
>createBrandFormElements['pubCheckBox']);


}


$browser
-
>type($this
-
>createBrandFormElements['pubAppName'],$brand['appName']);


}else{


if($browser
-
>isChecked($this
-
>createBrandFormElement
s['pubCheckBox'])){


//$browser
-
>type($this
-
>createBrandFormElements['pubAppName'],'');


$browser
-
>click($this
-
>createBrandFormElements['pubCheckBox']);


}


}


}




/**


* removes the brand


*


* @param type $browser
-

browser with some client's 'Brands' tab opened in it


* @param type $brandName
-

name of brand to be deleted


* @param type $cancel
-

click on 'cancel' link when there is no need to delete the brand


*/


function _removeBrand(&$browser, $brandName, $cancel = FALSE)


{


// path to the 'remove' link for the brand


$pathRemove =
"/
/*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span/b[text()='$brandName']/../../a[1][text()='remove']";


SeleniumBase::_waitForElement($browser, $pathRemove);


$browser
-
>click($pathRemove);




// path to 'Do you wa
nt remove?'
-

removing confirmation link


$confirmRemoving =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$brandName']/../../span[2]/a[2][text()='Do
you want remove?']";


// path to 'cancel'
-

cancel removin
g link


$cancelRemoving =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$brandName']/../../span[2]/a[1][text()='can
cel']";


SeleniumBase::_waitForElement($browser, $confirmRemoving);


SeleniumBase::_wa
itForElement($browser, $cancelRemoving);




sleep(1);

26



if(FALSE !== $cancel){




$browser
-
>click($cancelRemoving);


// locator to the appeared 'remove' link


$removeAppeared =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span[1]/b[text()='$brandName']/../../span[2]/a[text()='remov
e']";


SeleniumBase::_waitForElement($browser, $removeAppeared);


}else{




$browser
-
>click($confirmRemoving);


SeleniumBase::_waitForTextNot($browser, $brandName);


}


}




/**


*


* @param type $browser
-

browser with opened 'Brands' tab for some client


* @p
aram type $brandName
-

name of brand to be edited


* @param type $newBrand
-

new brand's info


* @param type $cancel
-

should we click 'cancel' or not


* @param type $giveRights
-

should we give rights to the app or not


*/


function

_editBrand(&$browser, $brandName, $newBrand, $giveRights = TRUE, $cancel = FALSE)


{


// path to 'edit' link for the brand


$editLink =
"//*[@id='admin_account_content']/table/tbody/tr/td[2]/div[1]/span/b[text()='$brandName']/../../a[2][t
ext()='edit']";


SeleniumBase::_waitForElement($browser, $editLink);


$browser
-
>click($editLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>saveBrandBtnLocator);




/**


* because of 'Publisher' checkbox bug


*/


$rightsFlag = (((isset($newBrand['appName']))||($browser
-
>isChecked($this
-
>crea
teBrandFormElements['pubCheckBox'])))


||((!isset($newBrand['appName']))&&(!$browser
-
>isChecked($this
-
>createBrandFormElements['pubCheckBox']))))


? TRUE : FALSE;




$this
-
>_typeBrandData($browser,

$newBrand);




if(FALSE === $cancel){




$browser
-
>click($this
-
>saveBrandBtnLocator);




if($rightsFlag){




if(TRUE === $giveRights){





SeleniumBase::_waitForElement($browser, $this
-
>giveRights);


$browser
-
>click($this
-
>giveRights);


}else{




SeleniumBase::_waitForElement
($browser, $this
-
>skipGivingRights);


$browser
-
>click($this
-
>skipGivingRights);


}


}




SeleniumBase::_waitForText($browser, 'Add new Brand');


SeleniumBase::_waitForText($browser, $brandName);

27



return TRUE;




}else{




$browser
-
>click($this
-
>createBrandFormElements['c
ancel']);


SeleniumBase::_waitForText($browser, 'Add new Brand');


SeleniumBase::_waitForText($browser, $brandName);


return FALSE;


}




}




/**


*


* @param type $browser
-

browser with opened brands list tab for some client


*/


protected function _addBrandFormTesting($browser, $clientName)


{


// path to 'Add new Brand' link from client's brands list tab


$addNewBrandLin
k = "//*[@id='admin_account_content']/div/span/a[1]/span[text()='Add new Brand']";


// path to 'Brands' link from 'Add new Brand' tab


$brandsFromAddNewBrand = "//*[@id='admin_account_content']/form/div[1]/span/a[1]/span[text()='Brands']";









//
------

trying not to input anything




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>
createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$brand['siteURL']

= '';


$brand['fbPageId'] = '';


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);


SeleniumBase::_waitForText($browser, '
Facebook Page ID');


SeleniumBase::_waitForText($browser, "Value is required and can't be empty");


$browser
-
>click($brandsFromAddNewBrand);


SeleniumBase::_waitForElement($browser, $addNewBrandLink);




//
------





//
------

trying to reuse valid decimal facebook id




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>
createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$brand['siteURL'] = '';


$brand['fbPageId'] = 666;


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);


// p
ath to the created brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";

28



SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText($path);




// trying to crea
te another brand with the same facebook id


SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_w
aitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>a
ddBrandBtnLocator);


// a message should appear


SeleniumBase::_waitForText($browser, "Brand for same facebook page already exist. Try another facebook
page, please.");


// path to 'Close' link


$pathClose = "//*[@id='admin_acco
unt_content']/form/a[text()='Close']";


SeleniumBase::_waitForElement($browser, $pathClose);


$browser
-
>click($pathClose);


SeleniumBase::_waitForText($browser, "Add New Client");


SeleniumBase::_waitForText($browser, $clientName);


$this
-
>_getBrandsTab($browser, $clientName);


$this
-
>_removeBrand($browser, $brandName);




//
------




//
------

trying to
reuse valid string facebook page id




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$brand['siteURL'] = '';


$brand['fbPa
geId'] = 'zuck';


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);


// path to the created brand's text


$path="//*[@id='a
dmin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText($path);




// trying to create another brand with the same facebook id


SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);


// a message should app
ear


SeleniumBase::_waitForText($browser, "Brand for same facebook page already exist. Try another facebook
page, please.");


// path to 'Close' link


$pathClose = "//*[@id='admin_account_content']/form/a[text()='Close']";


Sele
niumBase::_waitForElement($browser, $pathClose);

29



$browser
-
>click($pathClose);


SeleniumBase::_waitForText($browser, "Add New Client");


SeleniumBase::_waitForText($browser, $clientName);


$this
-
>_getBrandsTab($browser, $clientN
ame);


$this
-
>_removeBrand($browser, $brandName);




//
------





//
------

trying to input definitely wrong string as FB page ID




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>
addBrandBtnLocator);




$brand['siteURL'] = '';


$brand['fbPageId'] = SeleniumBase::_getRandSymbolStr(20);


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typ
eBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);


SeleniumBase::_waitForText($browser, 'Facebook Page ID');


SeleniumBase::_waitForText($browser, 'is not a valid HTTP path');


$browser
-
>click($brandsFro
mAddNewBrand);


SeleniumBase::_waitForElement($browser, $addNewBrandLink);




//
------






//
------

trying to use illegal page id string




SeleniumBase::_waitForElement($browser, $ad
dNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addB
randBtnLocator);




$brand['siteURL'] = '';


$brand['fbPageId'] = SeleniumBase::_getRandStr(25);


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>
_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);


SeleniumBase::_waitForText($browser, 'Facebook Page ID');


SeleniumBase::_waitForText($browser, 'Invalid response for the page');


SeleniumBase::_wa
itForText($browser, 'Try again or another page name, please.');


$browser
-
>click($brandsFromAddNewBrand);


SeleniumBase::_waitForElement($browser, $addNewBrandLink);




//
------






//
------

'Site URL' input bug: input data is not verified!!




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){



SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);

30





$brand['siteURL'] = SeleniumBase::_getRandSymbolStr(30
);


$brand['fbPageId'] = SeleniumBase::_getRandNumberStr(20);


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);




//locator to newly created brand


$elementToWait = "//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b[contains(.,'DEV
-
')]";


SeleniumBase::_waitForElement($browser, $elementToWait);



// path to the created

brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText($path);




$this
-
>_removeBrand($browser, $bran
dName);




//
------






//
------

'Twitter ID' input bug: input data is not verified!!




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);





foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$brand['siteURL'] = '';


$brand['fbPageId'] = SeleniumBase::_getRandNumberStr(20);


$brand['twitterId'] = SeleniumBase::_getRandSymbolStr(30);


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);




//locator to newly created brand


$elementToWait = "//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b[contains(.,'DEV
-
')]";


SeleniumBase::_waitForEleme
nt($browser, $elementToWait);



// path to the created brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText
($path);


$this
-
>_removeBrand($browser, $brandName);




//
------






//
------

'Youtube ID' input bug: input data is not verified!!




SeleniumBase::_waitForElement($browser, $addNewBr
andLink);


$browser
-
>click($addNewBrandLink);




foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBt
nLocator);




$brand['siteURL'] = '';


$brand['fbPageId'] = SeleniumBase::_getRandNumberStr(20);


$brand['twitterId'] = '';


$brand['youtubeId'] = SeleniumBase::_getRandSymbolStr(30);

31



$this
-
>
_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);




//locator to newly created brand


$elementToWait = "//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b[contains(.,'DEV
-
')]";



SeleniumBase::_waitForElement($browser, $elementToWait);



// path to the created brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);



$brandName = $browser
-
>getText($path);


$this
-
>_removeBrand($browser, $brandName);




//
------






//
-------------------

'Facebook Page ID' input bug
--------------------




// trying different decimal facebook ids


for($i = 1; $i <= 3; $i++){




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);



foreach($this
-
>createBrandF
ormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);



$brand['siteURL'] = '';


$brand['fbPageId'] = SeleniumBase::_getRandNumberStr($i * 10 + 5);


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnL
ocator);



//locator to newly created brand


$elementToWait = "//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser, $elementToWait);



// path to the c
reated brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText($path);



$this
-
>_removeBrand($
browser, $brandName);


}






// trying different hex facebook ids


for($i = 1; $i <= 3; $i++){




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($
addNewBrandLink);



foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);



$brand['siteURL'] = '';


$brand['fbPageId'] = SeleniumBase::_getRandHexNumStr($i * 10 + 5);


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);

32




//locator to newly created brand


$elementToWait = "//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,

$elementToWait);



// path to the created brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>get
Text($path);



$this
-
>_removeBrand($browser, $brandName);


}






// BUG: trying to reuse invalid decimal facebook ids and everything is ok


$id = SeleniumBase::_getRandNumberStr(20);


for($i = 1; $i <=
3; $i++){




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>click($addNewBrandLink);



foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);



$brand['siteURL'] = '';


$brand['fbPageId'] = $id;



$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandBtnLocator);



//locator to newly created brand


$elementToWait = "
//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser, $elementToWait);



// path to the created brand's text


$path="//*[@id='admin_account_content']/table/tbody/t
r[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText($path);



$this
-
>_removeBrand($browser, $brandName);


}






// BUG: trying
to reuse invalid decimal facebook ids and everything is ok


$id = SeleniumBase::_getRandHexNumStr(20);


for($i = 1; $i <= 3; $i++){




SeleniumBase::_waitForElement($browser, $addNewBrandLink);


$browser
-
>
click($addNewBrandLink);



foreach($this
-
>createBrandFormElements as $item){


SeleniumBase::_waitForElement($browser, $item );


}


SeleniumBase::_waitForElement($browser, $this
-
>addBrandBtnLocator);




$brand['siteURL'] = '';


$brand['fbPageId'] = $id;


$brand['twitterId'] = '';


$brand['youtubeId'] = '';


$this
-
>_typeBrandData($browser, $brand);


$browser
-
>click($this
-
>addBrandB
tnLocator);



//locator to newly created brand

33



$elementToWait = "//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser, $elementToWait);



// path to th
e created brand's text


$path="//*[@id='admin_account_content']/table/tbody/tr[1]/td[2]/div[1]/span/b";


SeleniumBase::_waitForElement($browser,$path);


$brandName = $browser
-
>getText($path);



$this
-
>_removeBran
d($browser, $brandName);


}




}

}


?>




34


Висновок

Під час проходження практики я використовував знання та навички, здобуті
мною в університеті, та вдосконалював їх. Я вважаю, що виробнича практика грає
дуже важливу
роль, оскільки вона є джерелом накопичення практичного досвіду
роботи по вибраній спеціальності та закріплення теоретичних знань. Вона сприяє
підготовці спеціалістів високого рівня, які б

вміло використовували термінологію та
володіли сучасними технологія
ми.