-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from WwwwwyDev/develop
Develop
- Loading branch information
Showing
10 changed files
with
186 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .script import Script | ||
from .action import Action | ||
from .annotation import check, alias | ||
from __version__ import __version__ as version | ||
from .pojo import Variable, VariableBase | ||
from .__version__ import __version__ as version |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
from .slide import Slide | ||
from .select import Select | ||
from .get import Get | ||
from .window import Window |
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,45 @@ | ||
from selenium.common import NoSuchWindowException | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.remote.webdriver import WebDriver | ||
|
||
from crawlipt.annotation import check, alias | ||
|
||
|
||
class Window: | ||
@staticmethod | ||
@check(exclude="driver") | ||
def clear(driver: WebDriver) -> None: | ||
""" | ||
close all windows | ||
:param driver: selenium webdriver | ||
""" | ||
for _ in range(driver.window_handles.__len__()-1): | ||
driver.close() | ||
driver.get("data:,") | ||
|
||
@staticmethod | ||
@check(exclude="driver") | ||
def back(driver: WebDriver) -> None: | ||
""" | ||
Goes one step backward in the browser history. | ||
:param driver: selenium webdriver | ||
""" | ||
driver.back() | ||
|
||
@staticmethod | ||
@check(exclude="driver") | ||
def forword(driver: WebDriver) -> None: | ||
""" | ||
Goes one step forward in the browser history. | ||
:param driver: selenium webdriver | ||
""" | ||
driver.forward() | ||
|
||
@staticmethod | ||
@check(exclude="driver") | ||
def close(driver: WebDriver) -> None: | ||
""" | ||
Closes the current window. | ||
:param driver: selenium webdriver | ||
""" | ||
driver.close() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import json | ||
from typing import Any | ||
|
||
from crawlipt.annotation import check | ||
|
||
|
||
class VariableBase: | ||
|
||
@check | ||
def get(self, key: str) -> Any: | ||
raise NotImplementedError | ||
|
||
@check(exclude="value") | ||
def set(self, key: str, value: Any) -> Any: | ||
raise NotImplementedError | ||
|
||
@check | ||
def __contains__(self, key: str): | ||
raise NotImplementedError | ||
|
||
|
||
class Variable(VariableBase): | ||
@check | ||
def __init__(self, values: dict | str): | ||
if isinstance(values, str): | ||
values: dict = json.load(values) | ||
self.values = values | ||
|
||
@check | ||
def get(self, key: str) -> Any: | ||
return self.values.get(key) | ||
|
||
@check(exclude="value") | ||
def set(self, key: str, value: Any): | ||
self.values[key] = value | ||
|
||
@check | ||
def __contains__(self, key: str): | ||
return key in self.values | ||
|
||
|
||
class VariableError(Exception): | ||
def __init__(self, message): | ||
self.message = message | ||
|
||
def __str__(self): | ||
return self.message |
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