Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(Internal): 📝 updated missing docs #407

Merged
merged 3 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ This is the configuration file for Boyka Framework named `boyka-config.json` sto
"browser": "CHROME",
"highlight": true,
"headless": false,
"resize": "CUSTOM"
"resize": "CUSTOM",
"custom_size": {
"width": 1580,
"height": 1080
}
},
"test_local_firefox": {
"browser": "FIREFOX"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

import static com.github.wasiqb.boyka.actions.CommonActions.getDriverAttribute;
import static com.github.wasiqb.boyka.actions.CommonActions.performDriverAction;
import static com.github.wasiqb.boyka.enums.Message.DRIVER_CANNOT_BE_NULL;
import static com.github.wasiqb.boyka.enums.Message.ERROR_SAVING_SCREENSHOT;
import static com.github.wasiqb.boyka.sessions.ParallelSession.getSession;
import static com.github.wasiqb.boyka.utils.ErrorHandler.handleAndThrow;
import static com.github.wasiqb.boyka.utils.ErrorHandler.requireNonNull;
import static com.google.common.truth.Truth.assertThat;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.lang3.StringUtils.EMPTY;
Expand Down Expand Up @@ -175,7 +177,7 @@ public void takeScreenshot (final String fileName) {
return;
}
performDriverAction (driver -> {
final var file = ((TakesScreenshot) driver).getScreenshotAs (FILE);
final var file = ((TakesScreenshot) requireNonNull (driver, DRIVER_CANNOT_BE_NULL)).getScreenshotAs (FILE);
try {
copyFile (file, new File (fileName));
} catch (final IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public enum Message {
* Content type must be set before setting request body
*/
CONTENT_TYPE_NOT_SET ("Content type must be set before setting request body..."),
/**
* Error when driver is null.
*/
DRIVER_CANNOT_BE_NULL ("Driver cannot be null, make sure you started the session correctly.."),
/**
* WebDriver's error occurred.
*/
Expand Down Expand Up @@ -181,6 +185,10 @@ public enum Message {
* Appium server already running.
*/
SERVER_ALREADY_RUNNING ("Appium server already running..."),
/**
* Error when starting session.
*/
SESSION_NOT_STARTED ("Session could not be started..."),
/**
* Test Error.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import java.net.URL;

import com.github.wasiqb.boyka.config.ui.web.WebSetting;
import com.github.wasiqb.boyka.enums.Message;
import com.github.wasiqb.boyka.enums.TargetProviders;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.SessionNotCreatedException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
Expand All @@ -51,26 +53,30 @@ class WebDriverManager implements IDriverManager {
public void setupDriver () {
LOGGER.traceEntry ();
final var webSetting = getSession ().getWebSetting ();
switch (requireNonNull (webSetting.getBrowser (), EMPTY_BROWSER_NOT_ALLOWED)) {
case CHROME:
setDriver (setupChromeDriver (webSetting));
break;
case NONE:
throwError (INVALID_BROWSER);
break;
case REMOTE:
setDriver (setupRemoteDriver (webSetting));
break;
case SAFARI:
setDriver (setupSafariDriver ());
break;
case EDGE:
setDriver (setupEdgeDriver (webSetting));
break;
case FIREFOX:
default:
setDriver (setupFirefoxDriver (webSetting));
break;
try {
switch (requireNonNull (webSetting.getBrowser (), EMPTY_BROWSER_NOT_ALLOWED)) {
case CHROME:
setDriver (setupChromeDriver (webSetting));
break;
case NONE:
throwError (INVALID_BROWSER);
break;
case REMOTE:
setDriver (setupRemoteDriver (webSetting));
break;
case SAFARI:
setDriver (setupSafariDriver ());
break;
case EDGE:
setDriver (setupEdgeDriver (webSetting));
break;
case FIREFOX:
default:
setDriver (setupFirefoxDriver (webSetting));
break;
}
} catch (final SessionNotCreatedException e) {
handleAndThrow (Message.SESSION_NOT_STARTED, e);
}
setDriverSize (webSetting);
navigateToBaseUrl (webSetting.getBaseUrl ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void handleAndThrow (final Message message, final Throwable cause,
*/
public static <T> T requireNonNull (final T subject, final Message throwMessage, final Object... args) {
if (subject == null) {
throw new FrameworkError (format (throwMessage.getMessageText (), args));
throwError (throwMessage, args);
}
return subject;
}
Expand Down
76 changes: 76 additions & 0 deletions core-java/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2023, Wasiq Bhamla
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
-->

<Configuration status="warn" name="Boyka-Logs">
<Properties>
<Property name="log-path">logs</Property>
<Property name="error-log">boyka-log-error</Property>
<Property name="all-log">boyka-log-all</Property>
<Property name="test-log">boyka-log-main</Property>
<Property name="log-pattern">
[%d{HH:mm:ss.SSS}] [%-5level] [%tn] - %msg (%logger{1}:%method:%L) %throwable{short.message}%n
</Property>
</Properties>
<ThresholdFilter level="debug"/>
<Appenders>
<Console name="console-log">
<PatternLayout pattern="${log-pattern}"/>
<ThresholdFilter level="debug"/>
</Console>
<RollingFile name="all-log-appender" fileName="${log-path}/${all-log}.log"
filePattern="${log-path}/${all-log}-%d{yyyy-MM-dd}.log" append="false" immediateFlush="true">
<PatternLayout>
<Pattern>${log-pattern}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
</RollingFile>
<RollingFile name="test-log-appender" fileName="${log-path}/${test-log}.log"
filePattern="${log-path}/${test-log}-%d{yyyy-MM-dd}.log" append="false" immediateFlush="true">
<PatternLayout>
<Pattern>${log-pattern}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
</RollingFile>
<RollingFile name="error-log-appender" fileName="${log-path}/${error-log}.log"
filePattern="${log-path}/${error-log}-%d{yyyy-MM-dd}.log" append="false" immediateFlush="true">
<PatternLayout>
<Pattern>${log-pattern}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="5 MB"/>
</Policies>
</RollingFile>
<Async name="Async">
<AppenderRef ref="test-log-appender"/>
</Async>
</Appenders>
<Loggers>
<Root level="all">
<AppenderRef ref="console-log" level="info"/>
<AppenderRef ref="Async" level="info"/>
<AppenderRef ref="all-log-appender" level="trace"/>
<AppenderRef ref="error-log-appender" level="error"/>
</Root>
</Loggers>
</Configuration>
81 changes: 0 additions & 81 deletions core-java/src/main/resources/log4j2.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion core-java/src/test/resources/boyka-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"browser": "CHROME",
"highlight": true,
"headless": false,
"resize": "CUSTOM"
"resize": "CUSTOM",
"custom_size": {
"width": 1580,
"height": 1080
}
},
"test_local_firefox": {
"browser": "FIREFOX"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"devDependencies": {
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@types/node": "^18.14.4",
"@types/node": "^18.14.5",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"commitlint": "^17.4.4",
Expand All @@ -47,7 +47,7 @@
"lerna": "^6.5.1",
"lerna-changelog": "^2.2.0",
"lint-staged": "^13.1.2",
"nx": "^15.8.1",
"nx": "^15.8.3",
"prettier": "^2.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
6 changes: 4 additions & 2 deletions website/docs/api/actions/elements/clickable-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ withMouse (locator).clickAndHold ();

### `dragTo (locator)` {#drag-to}

This method is used to drag and drop on the given element.
This method is used to drag source element and drop it on the target element.

```java
import static com.github.wasiqb.boyka.actions.elements.ClickableActions.withMouse;
. . .
withMouse (locator).dragTo ();
Locator source = // source element to drag
Locator target = // target element to drag the source to
withMouse (source).dragTo (target);
```

### `hover`
Expand Down
6 changes: 3 additions & 3 deletions website/docs/api/actions/elements/finger-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ This method will drag the source element to the target element.
```java
import static com.github.wasiqb.boyka.actions.elements.FingerActions.withFinger;
. . .
WebElement sourceElement = // source element to drag
WebElement targetElement = // target element to drag the source to
withFinger (sourceElement).dragTo (targetElement);
Locator source = // source element to drag
Locator target = // target element to drag the source to
withFinger (source).dragTo (target);
```

### `swipeTill`
Expand Down
Loading