Add closeGooglePlayBannerIfVisible to handle Google Play update banners:
- Ensure banners are closed during transaction fetching in `GetLastTransactionsScript`. - Update XML parsing workflow to accommodate banner dismissal logic.
This commit is contained in:
parent
d0330a509a
commit
d59bf51416
@ -224,6 +224,18 @@ bool CommonScript::tryToCloseAllBannersOnHomePage(const QString &deviceId, const
|
||||
return closedAny;
|
||||
}
|
||||
|
||||
bool CommonScript::closeGooglePlayBannerIfVisible(
|
||||
const QString &deviceId, const int width, const int height
|
||||
) {
|
||||
Node gpNode = xmlScreenParser.tryToFindGooglePlayBanner(width, height);
|
||||
if (gpNode.isEmpty()) return false;
|
||||
qDebug() << "[Ozon] Google Play update banner detected mid-task, closing...";
|
||||
AdbUtils::makeTap(deviceId, gpNode.x(), gpNode.y());
|
||||
QThread::msleep(1500);
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(deviceId, ++m_counter));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommonScript::goToAllProducts(
|
||||
const QString &deviceId,
|
||||
const int width,
|
||||
|
||||
@ -57,6 +57,12 @@ protected:
|
||||
const QString &deviceId, int width, int height
|
||||
);
|
||||
|
||||
// Если виден баннер Google Play "Доступно обновление" — закрывает его и перепарсивает XML.
|
||||
// Безопасно вызывать на любом экране; возвращает true если баннер был закрыт.
|
||||
bool closeGooglePlayBannerIfVisible(
|
||||
const QString &deviceId, int width, int height
|
||||
);
|
||||
|
||||
// Создаёт bank_profile на сервере если ещё не создан
|
||||
void createBankProfileIfNeeded(const QString &deviceId, const QString &appCode, double parsedBalance = -1.0);
|
||||
|
||||
|
||||
@ -296,6 +296,7 @@ void GetLastTransactionsScript::searchTransaction(const DeviceInfo &device, int
|
||||
// Ждём пока WebView раскроет accessibility tree (иначе dump пустой)
|
||||
for (int wait = 0; wait < 5; ++wait) {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
closeGooglePlayBannerIfVisible(m_deviceId, device.screenWidth, device.screenHeight);
|
||||
if (xmlScreenParser.findTransactionButtons(1).size() > 0) break;
|
||||
if (hasDateOnScreen()) break;
|
||||
qDebug() << "[FetchTransactions] Waiting for WebView content..." << (wait + 1);
|
||||
@ -311,6 +312,7 @@ void GetLastTransactionsScript::searchTransaction(const DeviceInfo &device, int
|
||||
return;
|
||||
}
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
closeGooglePlayBannerIfVisible(m_deviceId, device.screenWidth, device.screenHeight);
|
||||
if (hasDateOnScreen()) {
|
||||
dateFound = true;
|
||||
scrollsToDate = scroll;
|
||||
@ -384,6 +386,7 @@ void GetLastTransactionsScript::searchTransaction(const DeviceInfo &device, int
|
||||
return;
|
||||
}
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
closeGooglePlayBannerIfVisible(m_deviceId, device.screenWidth, device.screenHeight);
|
||||
|
||||
// Логируем все заголовки дат на экране
|
||||
{
|
||||
@ -451,6 +454,7 @@ void GetLastTransactionsScript::searchTransaction(const DeviceInfo &device, int
|
||||
return;
|
||||
}
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
closeGooglePlayBannerIfVisible(m_deviceId, device.screenWidth, device.screenHeight);
|
||||
detail = xmlScreenParser.parseTransactionDetail();
|
||||
if (!detail.bankTime.isEmpty()) break;
|
||||
if (xmlScreenParser.isTransactionListScreen()) {
|
||||
@ -684,6 +688,7 @@ void GetLastTransactionsScript::scanRecentTransactions(const DeviceInfo &device,
|
||||
QList<Node> txButtons;
|
||||
for (int attempt = 0; attempt < 5; ++attempt) {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
closeGooglePlayBannerIfVisible(m_deviceId, device.screenWidth, device.screenHeight);
|
||||
txButtons = xmlScreenParser.findTransactionButtons(8);
|
||||
if (!txButtons.isEmpty()) break;
|
||||
QThread::msleep(1500);
|
||||
@ -719,6 +724,7 @@ void GetLastTransactionsScript::scanRecentTransactions(const DeviceInfo &device,
|
||||
TransactionInfo detail;
|
||||
for (int attempt = 0; attempt < 10; ++attempt) {
|
||||
xmlScreenParser.parseAndSaveXml(AdbUtils::getScreenDumpAsXml(m_deviceId, ++m_counter));
|
||||
closeGooglePlayBannerIfVisible(m_deviceId, device.screenWidth, device.screenHeight);
|
||||
detail = xmlScreenParser.parseTransactionDetail();
|
||||
if (!detail.bankTime.isEmpty()) break;
|
||||
if (xmlScreenParser.isTransactionListScreen()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user