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.
51 lines
1.7 KiB
51 lines
1.7 KiB
import { chromium } from "playwright";
|
|
|
|
async function main() {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage();
|
|
await page.goto(
|
|
"https://www.priority1.com/instant-freight-quotes/#New%20Step%201",
|
|
{ waitUntil: "domcontentloaded" },
|
|
);
|
|
await page.locator("#container-mh").waitFor();
|
|
await page.waitForTimeout(2000);
|
|
|
|
const info = await page.evaluate(() => {
|
|
const ltl = document.querySelector("#cb_st_ltl") as HTMLInputElement | null;
|
|
return {
|
|
exists: !!ltl,
|
|
checked: ltl?.checked,
|
|
display: ltl ? getComputedStyle(ltl).display : null,
|
|
visibility: ltl ? getComputedStyle(ltl).visibility : null,
|
|
opacity: ltl ? getComputedStyle(ltl).opacity : null,
|
|
inMh: !!ltl?.closest("#container-mh"),
|
|
};
|
|
});
|
|
console.log("ltl:", info);
|
|
|
|
await page
|
|
.locator("#container-mh")
|
|
.getByText(/Less Than Truckload/i)
|
|
.first()
|
|
.click({ noWaitAfter: true });
|
|
await page.waitForTimeout(800);
|
|
|
|
const after = await page.evaluate(() => {
|
|
const ltl = document.querySelector("#cb_st_ltl") as HTMLInputElement | null;
|
|
const all = [...document.querySelectorAll("#cb_st_ltl")].map((el) => ({
|
|
checked: (el as HTMLInputElement).checked,
|
|
inMh: !!el.closest("#container-mh"),
|
|
}));
|
|
const zipVisible = !!document.querySelector("#container-mh #origin-zip");
|
|
const zipDisabled = (
|
|
document.querySelector("#container-mh #origin-zip") as HTMLInputElement | null
|
|
)?.disabled;
|
|
return { checked: ltl?.checked, all, zipVisible, zipDisabled };
|
|
});
|
|
console.log("after card click:", after);
|
|
|
|
await browser.close();
|
|
}
|
|
|
|
main().catch(console.error);
|