-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 27 additions & 1 deletion
28
pogen4selenium-api/src/main/java/io/toolisticon/pogen4selenium/api/ActionFileUpload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
package io.toolisticon.pogen4selenium.api; | ||
|
||
public @interface ActionFileUpload { | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import io.toolisticon.pogen4selenium.runtime.DefaultSideCondition; | ||
import io.toolisticon.pogen4selenium.runtime.LocatorCondition; | ||
import io.toolisticon.pogen4selenium.runtime.actions.ActionFileUploadImpl; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Action(ActionFileUploadImpl.class) | ||
public @interface ActionFileUpload { | ||
/** | ||
* The locator type to use. Can be ELEMENT for using a generated element or any kind of locator provided by selenium. | ||
* @return the locator to use. | ||
*/ | ||
_By by() default _By.ELEMENT; | ||
|
||
/** The locator string to use. */ | ||
String value(); | ||
|
||
/** | ||
* The locator strategy to use, will just be taken into account if by attribute is not set to ELEMENT. | ||
* @return the Locator strategy, defaults to DefaultLocatorStrategy | ||
*/ | ||
@ActionSideCondition | ||
Class<? extends LocatorCondition> actionSideCondition() default DefaultSideCondition.class; | ||
} |
39 changes: 39 additions & 0 deletions
39
...api/src/main/java/io/toolisticon/pogen4selenium/runtime/actions/ActionFileUploadImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.toolisticon.pogen4selenium.runtime.actions; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.SearchContext; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import io.toolisticon.pogen4selenium.runtime.LocatorCondition; | ||
|
||
public class ActionFileUploadImpl extends BaseAction { | ||
|
||
private final File file; | ||
|
||
public ActionFileUploadImpl(WebDriver driver, SearchContext searchContext, LocatorCondition sideCondition, File file) { | ||
super(driver, searchContext, sideCondition); | ||
this.file = file; | ||
} | ||
|
||
@Override | ||
public boolean checkCondition(WebDriver driver, WebElement element) { | ||
return element.isDisplayed() && element.isEnabled(); | ||
} | ||
|
||
@Override | ||
public Collection<Class<? extends Throwable>> exceptionsToIgnore() { | ||
return Arrays.asList(NoSuchElementException.class); | ||
} | ||
|
||
|
||
@Override | ||
protected void applyAction(WebElement webElement) { | ||
webElement.sendKeys(file.getAbsolutePath()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters