You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.7 KiB
36 lines
1.7 KiB
# -*- coding: utf-8 -*-
|
|
"""对比:不 dispatch load 直接截图,看页面是否可见"""
|
|
import io, sys, time
|
|
from pathlib import Path
|
|
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
P = Path(r'e:\code\crm-backend-matt\.scratch\a7-parity\pages\a7-3-1_线索规则')
|
|
url = 'file:///' + str((P / 'a7-3-1_线索规则.html')).replace('\\', '/')
|
|
|
|
from playwright.sync_api import sync_playwright
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch()
|
|
ctx = browser.new_context(viewport={'width': 1600, 'height': 900})
|
|
ctx.add_init_script("window.lanhu_Axure_Mapping_Data = function(d){ return d; };")
|
|
page = ctx.new_page()
|
|
page.goto(url, wait_until='domcontentloaded', timeout=20000)
|
|
time.sleep(3)
|
|
dim = page.evaluate("() => [document.documentElement.scrollWidth, document.documentElement.scrollHeight]")
|
|
print('dim (no dispatch):', dim)
|
|
vis = page.evaluate("""() => {
|
|
const b = document.getElementById('base');
|
|
const cs = getComputedStyle(b);
|
|
// 沿祖先链找隐藏者
|
|
let el = b, chain = [];
|
|
while (el && el !== document.documentElement) {
|
|
const s = getComputedStyle(el);
|
|
if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0')
|
|
chain.push({id: el.id || el.tagName, display: s.display, vis: s.visibility, op: s.opacity});
|
|
el = el.parentElement;
|
|
}
|
|
return {baseVis: cs.visibility, baseDisp: cs.display, hiddenChain: chain};
|
|
}""")
|
|
print('visibility chain:', vis)
|
|
page.screenshot(path=str(P.parent.parent / 'shots' / 'debug-nodispatch.png'), full_page=True)
|
|
print('saved debug-nodispatch.png')
|
|
browser.close()
|
|
|