diff --git a/frontend/src/app/selenium/test-selenium.component.css b/frontend/src/app/selenium/test-selenium.component.css
index e69de29..a1e7fb3 100644
--- a/frontend/src/app/selenium/test-selenium.component.css
+++ b/frontend/src/app/selenium/test-selenium.component.css
@@ -0,0 +1,7 @@
+.showModelResult{
+ width: 100%; background-color: rgba(0, 0, 0, 0.4); height: 100vh;position: absolute;left: 0;top: 0; z-index: 9999;
+}
+
+.hideIt{
+ visibility: hidden;
+}
\ No newline at end of file
diff --git a/frontend/src/app/selenium/test-selenium.component.html b/frontend/src/app/selenium/test-selenium.component.html
index cd50b92..5b08d54 100644
--- a/frontend/src/app/selenium/test-selenium.component.html
+++ b/frontend/src/app/selenium/test-selenium.component.html
@@ -1,4 +1,53 @@
+
+
diff --git a/frontend/src/app/selenium/test-selenium.component.ts b/frontend/src/app/selenium/test-selenium.component.ts
index 58c74af..cd4ca65 100644
--- a/frontend/src/app/selenium/test-selenium.component.ts
+++ b/frontend/src/app/selenium/test-selenium.component.ts
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component, Renderer2, ElementRef } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
@@ -7,8 +7,8 @@ import { HttpClient } from '@angular/common/http';
styleUrls: ['./test-selenium.component.css']
})
export class TestSeleniumComponent {
- constructor(private http: HttpClient) { }
-
+ constructor(private http: HttpClient,private renderer: Renderer2, private el: ElementRef) { }
+ testResult: any;
counterAction: number=1;
counterCase: number=0;
cases : {
@@ -23,21 +23,48 @@ export class TestSeleniumComponent {
target: string;
}[] ;
}[] = [];
+ percentage=0;
runMethod(cases: any) {
- const apiUrl = '/api/testselenium';
- console.log(cases);
- this.http.post(apiUrl, cases).subscribe(
+ let counterTrue=0;
+ const API_URL = 'http://localhost:8080/api/testselenium';
+ this.showResultModal();
+ this.showSpinner();
+ this.http.post(API_URL, cases).subscribe(
(response) => {
console.log('tested successfully:', response);
-
+ this.testResult=response;
+ // for calculate the percentage of the success cases
+ for(let result of this.testResult){
+ if(result.success){
+ counterTrue++;
+ }
+ }
+ this.percentage=(counterTrue / this.testResult.length) * 100;
+ this.hideSpinner();
},
(error) => {
console.error('Error test:', error);
}
);
}
-
+ showResultModal(): void {
+ const resultModal = this.el.nativeElement.querySelector('#modelResult');
+ this.renderer.removeClass(resultModal, 'hideIt');
+ }
+ hideResultModal(): void {
+ const resultModal = this.el.nativeElement.querySelector('#modelResult');
+ this.renderer.addClass(resultModal, 'hideIt');
+ }
+ showSpinner():void {
+ const resultModal = this.el.nativeElement.querySelector('#spinner');
+ this.renderer.removeClass(resultModal, 'hideIt');
+ }
+ hideSpinner():void {
+ const resultModal = this.el.nativeElement.querySelector('#spinner');
+ this.renderer.addClass(resultModal, 'hideIt');
+ }
+ // for enable and disable inputs needed in actions form
actionChose(): void {
const action = (document.getElementById('action') as HTMLSelectElement).value;
const object = document.getElementById('object') as HTMLInputElement;
@@ -60,6 +87,7 @@ export class TestSeleniumComponent {
object.disabled = false;
}
}
+ //add new case
submitCase(){
this.counterCase++;
let caseName = (document.getElementById('caseName') as HTMLSelectElement).value;
@@ -83,9 +111,11 @@ export class TestSeleniumComponent {
this.cases.push(obj);
}
+ // add new action
submitAction(){
let action_id = parseInt((document.getElementById('action') as HTMLSelectElement).value);
- let action = (document.getElementById('action') as HTMLSelectElement).innerText;
+ let action2 = (document.getElementById('action') as HTMLSelectElement);
+ let action = action2.options[action2.selectedIndex].text;
let object = (document.getElementById('object') as HTMLInputElement).value;
let input = (document.getElementById('input') as HTMLInputElement).value;
let target = (document.getElementById('target') as HTMLInputElement).value;
diff --git a/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumCase.java b/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumCase.java
index 530355e..aca1b9b 100644
--- a/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumCase.java
+++ b/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumCase.java
@@ -7,6 +7,6 @@
@Data
public class SeleniumCase {
public int case_id;
- public String case_name;
+ public String caseName;
public List actions;
}
diff --git a/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumResponse.java b/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumResponse.java
index f19b401..385bdec 100644
--- a/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumResponse.java
+++ b/selenium/src/main/java/ca/etsmtl/selenium/requests/payload/request/SeleniumResponse.java
@@ -8,7 +8,7 @@
@Data
public class SeleniumResponse implements Serializable {
public int case_id;
- public String case_name;
+ public String caseName;
public List seleniumActions;
public boolean success;
public long timestamp;
diff --git a/selenium/src/main/java/ca/etsmtl/selenium/requests/useSelenium.java b/selenium/src/main/java/ca/etsmtl/selenium/requests/useSelenium.java
index b0b144d..4c5ab0f 100644
--- a/selenium/src/main/java/ca/etsmtl/selenium/requests/useSelenium.java
+++ b/selenium/src/main/java/ca/etsmtl/selenium/requests/useSelenium.java
@@ -26,7 +26,7 @@ public SeleniumResponse testWithSelenium(@RequestBody SeleniumCase seleniumCase)
SeleniumResponse seleniumResponse = new SeleniumResponse();
seleniumResponse.setCase_id(seleniumCase.getCase_id());
- seleniumResponse.setCase_name(seleniumCase.getCase_name());
+ seleniumResponse.setCaseName(seleniumCase.getCaseName());
seleniumResponse.setSeleniumActions(seleniumActions);
long currentTimestamp = (new Timestamp(System.currentTimeMillis())).getTime();
seleniumResponse.setTimestamp(currentTimestamp/1000);