Skip to content

Commit

Permalink
Merge pull request #24 from slu-it/select-performance
Browse files Browse the repository at this point in the history
Use performance enhanced implementation of Selenium's Select when creating events
  • Loading branch information
Drakojin authored Aug 24, 2016
2 parents fcca989 + 3671630 commit e00a4f2
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -18,6 +17,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.MultiSelect;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean needsBeforeData() {

@Override
public PageFragmentEventBuilder<DeselectedByIndicesEvent> setBeforeData(WebElement webElement) {
before = new Select(webElement).getAllSelectedOptions()
before = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("index")))
.map(Integer::parseInt)
Expand All @@ -73,7 +73,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<DeselectedByIndicesEvent> setAfterData(WebElement webElement) {
after = new Select(webElement).getAllSelectedOptions()
after = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("index")))
.map(Integer::parseInt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -18,6 +17,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.MultiSelect;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean needsBeforeData() {

@Override
public PageFragmentEventBuilder<DeselectedByTextsEvent> setBeforeData(WebElement webElement) {
before = new Select(webElement).getAllSelectedOptions()
before = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getText()))
.collect(Collectors.toList());
Expand All @@ -72,7 +72,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<DeselectedByTextsEvent> setAfterData(WebElement webElement) {
after = new Select(webElement).getAllSelectedOptions()
after = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getText()))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -18,6 +17,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.MultiSelect;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean needsBeforeData() {

@Override
public PageFragmentEventBuilder<DeselectedByValuesEvent> setBeforeData(WebElement webElement) {
before = new Select(webElement).getAllSelectedOptions()
before = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("value")))
.collect(Collectors.toList());
Expand All @@ -72,7 +72,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<DeselectedByValuesEvent> setAfterData(WebElement webElement) {
after = new Select(webElement).getAllSelectedOptions()
after = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("value")))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package info.novatec.testit.webtester.events.pagefragments;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -11,6 +10,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.SingleSelect;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -50,8 +50,9 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<SelectedByIndexEvent> setAfterData(WebElement webElement) {
Select select = new Select(webElement);
this.index = select.getOptions().indexOf(select.getFirstSelectedOption());
EnhancedSelect select = new EnhancedSelect(webElement);
String indexAsString = select.getFirstSelectedOption().getAttribute("index");
this.index = Integer.valueOf(indexAsString);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -18,6 +17,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.MultiSelect;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean needsBeforeData() {

@Override
public PageFragmentEventBuilder<SelectedByIndicesEvent> setBeforeData(WebElement webElement) {
before = new Select(webElement).getAllSelectedOptions()
before = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("index")))
.map(Integer::parseInt)
Expand All @@ -73,7 +73,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<SelectedByIndicesEvent> setAfterData(WebElement webElement) {
after = new Select(webElement).getAllSelectedOptions()
after = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("index")))
.map(Integer::parseInt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package info.novatec.testit.webtester.events.pagefragments;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -11,6 +10,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.SingleSelect;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -50,7 +50,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<SelectedByTextEvent> setAfterData(WebElement webElement) {
this.text = new Select(webElement).getFirstSelectedOption().getText();
this.text = new EnhancedSelect(webElement).getFirstSelectedOption().getText();
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -18,6 +17,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.MultiSelect;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean needsBeforeData() {

@Override
public PageFragmentEventBuilder<SelectedByTextsEvent> setBeforeData(WebElement webElement) {
before = new Select(webElement).getAllSelectedOptions()
before = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getText()))
.collect(Collectors.toList());
Expand All @@ -72,7 +72,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<SelectedByTextsEvent> setAfterData(WebElement webElement) {
after = new Select(webElement).getAllSelectedOptions()
after = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getText()))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package info.novatec.testit.webtester.events.pagefragments;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -11,6 +10,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.SingleSelect;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -50,7 +50,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<SelectedByValueEvent> setAfterData(WebElement webElement) {
this.value = new Select(webElement).getFirstSelectedOption().getAttribute("value");
this.value = new EnhancedSelect(webElement).getFirstSelectedOption().getAttribute("value");
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

import lombok.Getter;

Expand All @@ -18,6 +17,7 @@
import info.novatec.testit.webtester.events.PageFragmentEventBuilder;
import info.novatec.testit.webtester.pagefragments.MultiSelect;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pagefragments.utils.EnhancedSelect;


/**
Expand Down Expand Up @@ -58,7 +58,7 @@ public boolean needsBeforeData() {

@Override
public PageFragmentEventBuilder<SelectedByValuesEvent> setBeforeData(WebElement webElement) {
before = new Select(webElement).getAllSelectedOptions()
before = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("value")))
.collect(Collectors.toList());
Expand All @@ -72,7 +72,7 @@ public boolean needsAfterData() {

@Override
public PageFragmentEventBuilder<SelectedByValuesEvent> setAfterData(WebElement webElement) {
after = new Select(webElement).getAllSelectedOptions()
after = new EnhancedSelect(webElement).getAllSelectedOptions()
.stream()
.map(element -> StringUtils.defaultString(element.getAttribute("value")))
.collect(Collectors.toList());
Expand Down

0 comments on commit e00a4f2

Please sign in to comment.