AI开发playwright tool提示词
[TASK]
生成一个isModuleElementObject function,若element的qa-test class在对象moduleObj {"qa-test-mycourses-course": "qa-test-mycourses-course-title", "qa-test-discussion-module": "qa-test-discussion-description", "qa-test-reply-module": "qa-test-reply-description"}的key中,返回该key的value
生成一个getModuleText function,根据`.${value}`得到elementList,并返回所有element的textList
生成一个getUniqueLocatorsInModule function,传入rootElement,按照以下规则生成该元素下所有节点:
1.调用getModuleText,并根据text得到rootElement的uniqueLocator `${rootElement.locator}:has-text("${text}") ${element.locator}`
2.遍历每个子节点element,判断是否moduleElementsObject
2.当class包含qa-test时,获取该子节点的locator, 并返回
3.用isUnique判断,若元素唯一,则加入全局数组中
[Example]
以下是rootElement及其后代节点的信息,提供参考
<div class="qa-test-mycourses-course"><div class="tw-block tw-bg-white tw-p-4 tw-rounded-lg tw-shadow-lg"><a class="tw-block" title="AOS_BROWSE_Course028" href="/training/03374f80-07aa-4f60-b826-9b90810dcad3"><div class="qa-test-mycourses-course-title tw-text-2xl tw-text-black tw-font-extrabold tw-my-4 tw-line-clamp-1">AOS_BROWSE_Course028</div><div class="tw-flex tw-items-center"><svg width="12" height="13" fill="none" xmlns="http://www.w3.org/2000/svg" class="tw-align-middle tw-inline-block tw-mr-2"><path d="M3 9.5h3V8H3v1.5Zm0-2.25h6v-1.5H3v1.5ZM3 5h6V3.5H3V5Zm-1.5 7.5c-.413 0-.766-.147-1.06-.44A1.445 1.445 0 0 1 0 11V2c0-.413.147-.766.44-1.06C.735.648 1.088.5 1.5.5h9c.412 0 .766.147 1.06.44.293.294.44.647.44 1.06v9c0 .412-.147.766-.44 1.06-.294.293-.648.44-1.06.44h-9Zm0-1.5h9V2h-9v9Z" fill="#31728C"></path></svg><span class="tw-text-teal tw-font-extrabold">Course</span></div><div class="qa-test-mycourses-course-description tw-my-2 tw-text-black tw-text-base tw-line-clamp-1 tw-h-6">This is a course</div><div><div class="tw-h-1.5 tw-bg-line-1 tw-rounded-full tw-my-4 tw-overflow-hidden"><div class="tw-bg-medium-teal tw-h-full" style="width: 25%;"></div></div><div class="qa-test-mycourses-course-complete-status tw-flex tw-justify-between"><div>1 / 4 lessons completed</div><div>25% completed</div></div></div><div class="tw-my-4"><img class="tw-object-cover tw-h-[225px] tw-w-full qa-test-mycourses-course-cover" src="/img/default_cover.8c5844d2.png?x-bce-process=image/format,f_auto"></div></a><button type="input" class="qa-test-mycourses-learn-button tw-w-full tw-text-left"><div class="tw-flex tw-justify-between tw-items-center tw-my-3"><div class="tw-text-lg tw-text-black tw-font-extrabold">Next activity</div></div><div class="tw-my-2 tw-font-extrabold tw-text-teal tw-text-base tw-min-h-6">Lesson 1.2</div><div class="tw-mt-4 tw-rounded-full tw-text-center tw-leading-10 tw-border tw-border-teal tw-text-teal tw-font-extrabold">Continue learning</div></button></div></div>