autool/DroidBot/platforms/web/web_app.py
2026-06-17 19:44:18 +08:00

73 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Web App Module
Web-specific application model.
"""
import logging
import os
from ...core.abstract_app import AbstractApp
class WebApp(AbstractApp):
"""
Web 应用类 - 用于管理 Web 应用的信息
继承自 AbstractApp实现 Web 特定的应用管理功能。
"""
def __init__(self, url: str, output_dir: str = None):
"""
创建 WebApp 实例
:param url: Web 应用的 URL
:param output_dir: 输出目录路径
"""
super().__init__(output_dir=output_dir)
self.app_url = url # Web应用的URL
self._main_page = url # 主页面URL
self._pages = [] # 已访问页面列表
@property
def identifier(self) -> str:
"""获取应用唯一标识符URL"""
return self.app_url
@property
def main_activity(self) -> str:
"""获取主入口点主页面URL"""
return self._main_page
@main_activity.setter
def main_activity(self, value):
"""设置主入口点"""
self._main_page = value
@property
def activities(self) -> list:
"""获取入口点列表(已访问页面)"""
return self._pages
@activities.setter
def activities(self, value):
"""设置入口点列表"""
self._pages = value
def add_page(self, url: str):
"""
添加已访问页面
:param url: 已访问的页面URL
"""
if url not in self._pages:
self._pages.append(url)
def get_current_page(self, device) -> str:
"""
获取当前页面URL
:param device: WebDevice实例
:return: 当前页面URL
"""
if device and device._current_url:
return device._current_url
return self.app_url