How to use expect_navigation method in Playwright Python

Best Python code snippet using playwright-python

baseconfig.py

Source:baseconfig.py Github

copy

Full Screen

...20 page.press("input[placeholder=\"请输入管理员帐号\"]", "Tab")21 # Fill input[placeholder="请输入管理员密码"]22 page.fill("input[placeholder=\"请输入管理员密码\"]", "admin@1234")23 # Click input[name="log_bt"]24 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php"):25 with page.expect_navigation():26 page.click("input[name=\"log_bt\"]")27 # Click text="身份访问管理"28 page.click("text=\"身份访问管理\"")29 30 for i in range(usernumber):31 i = i + 132 temp = str(int(time.time()*1000))33 groupname = '组' + temp34 username = 'user' + temp35 # Click text="身份管理"36 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=13"):37 with page.expect_navigation():38 page.click("text=\"身份管理\"")39 # Click div[id="top222"] >> text="添加"40 page.click("div[id=\"top222\"] >> text=\"添加\"")41 # Click //tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']42 page.click("//tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']")43 # Fill //tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']44 page.fill("//tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']", groupname)45 # Click text="保存"46 page.click("text=\"保存\"")47 # Click text="返回列表"48 page.click("text=\"返回列表\"")49 # Click //div[3]/a[1]/span/span[1][normalize-space(.)='添加']50 page.click("//div[3]/a[1]/span/span[1][normalize-space(.)='添加']")51 # Fill //tr[normalize-space(.)='登录名: * ']/td[2]/span/input[1][normalize-space(@type)='text']52 page.fill("//tr[normalize-space(.)='登录名: * ']/td[2]/span/input[1][normalize-space(@type)='text']", username)53 # Fill //span/input[1][normalize-space(@type)='password']54 page.fill("//span/input[1][normalize-space(@type)='password']", "123123")55 # Fill //tr[normalize-space(.)='确认密码:  ']/td[2]/span/input[1][normalize-space(@type)='password']56 page.fill("//tr[normalize-space(.)='确认密码:  ']/td[2]/span/input[1][normalize-space(@type)='password']", "123123")57 #os.system("pause")58 page.waitForSelector("text=\"请选择组\"")59 60 # Click text="请选择组"61 page.click("text=\"请选择组\"")62 63 chosenbox = "//div[@id='popup-tree-group']//span[text()='"+groupname+"']/preceding-sibling::span[1]"64 #print(chosenbox) 65 page.click(chosenbox)66 # Click text="确定"67 page.click("text=\"确定\"")68 69 # Click text="保存"70 page.click("text=\"保存\"")71 72 # Click text="返回列表"73 page.click("text=\"返回列表\"")74 appnamegroup = ['一级应用','三级应用']75 appurlgroup = ['xxx33.com','xxx250.com']76 appipgroup = ['10.92.2.33','10.92.2.250']77 appportgroup = ['80','80']78 appnumber = len(appnamegroup)79 j = 080 for j in range(appnumber):81 temp = str(int(time.time()*1000))82 appname = appnamegroup[j]83 appurl =appurlgroup[j]84 appip = appipgroup[j]85 appport = appportgroup[j]86 j = j + 187 # Click text="资源管理"88 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114"):89 with page.expect_navigation():90 page.click("text=\"资源管理\"")91 92 # Click a[id="toolbar-add-person"] >> text=/.*添加.*/93 page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")94 # Click //td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']95 page.click("//td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']")96 # Fill //td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']97 page.fill("//td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']", appname + temp)98 # Click //td[normalize-space(.)='  删除 ']/span/input[1][normalize-space(@type)='text']99 page.click("//td[normalize-space(.)='  删除 ']/span/input[1][normalize-space(@type)='text']")100 # fill101 page.fill("//td[normalize-space(.)='  删除 ']/span/input[1][normalize-space(@type)='text']", appurl)102 # Click text="后台服务"103 page.click("text=\"后台服务\"")104 # Click td[id="update_server_list_add"] >> text="新增一组"105 page.click("td[id=\"update_server_list_add\"] >> text=\"新增一组\"")106 # Click //tr[normalize-space(.)='删除 ']/td[1]/span/input[1][normalize-space(@type)='text']107 page.click("//tr[normalize-space(.)='删除 ']/td[1]/span/input[1][normalize-space(@type)='text']")108 # Fill //tr[normalize-space(.)='删除 ']/td[1]/span/input[1][normalize-space(@type)='text']109 page.fill("//tr[normalize-space(.)='删除 ']/td[1]/span/input[1][normalize-space(@type)='text']", appip)110 # Fill //tr[normalize-space(.)='删除 ']/td[2]/span/input[1][normalize-space(@type)='text']111 page.fill("//tr[normalize-space(.)='删除 ']/td[2]/span/input[1][normalize-space(@type)='text']", appport)112 # Click text="保存"113 page.click("text=\"保存\"")114 115 temp1 = str(int(time.time()*1000))116 ippoolname = '薛ip池'117 # Click text="资源管理"118 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114"):119 with page.expect_navigation():120 page.click("text=\"资源管理\"")121 # Click div[id="subnav_2_15"] >> text="NC管理"122 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114&p=113"):123 # with page.expect_navigation():124 # page.click("div[id=\"subnav_2_15\"] >> text=\"NC管理\"")125 page.goto("https://" + tac + ":8443/admin/main.php?mid=114&p=113")126 # Click div[id="tabshead"] >> text="IP地址池"127 page.click("div[id=\"tabshead\"] >> text=\"IP地址池\"")128 # Click //div[2]/div/div/div[3]/a[1]/span/span[1][normalize-space(.)=' 添加 ']129 page.click("//div[2]/div/div/div[3]/a[1]/span/span[1][normalize-space(.)=' 添加 ']")130 # Click //tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']131 page.click("//tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']")132 # Fill //tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']133 page.fill("//tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']", ippoolname + temp1)134 # Click input[name="pool_start"]135 page.click("input[name=\"pool_start\"]")136 # Fill input[name="pool_start"]137 page.fill("input[name=\"pool_start\"]", "1.1.1.2")138 # Click input[name="pool_end"]139 page.click("input[name=\"pool_end\"]")140 # Fill input[name="pool_end"]141 page.fill("input[name=\"pool_end\"]", "1.1.1.22")142 # Click form[id="form1"] >> text="添加"143 page.click("form[id=\"form1\"] >> text=\"添加\"")144 # Click div[id="popup1-buttons"] >> text="保存"145 page.click("div[id=\"popup1-buttons\"] >> text=\"保存\"")146 temp2 = str(int(time.time()*1000))147 ncname = '薛nc设置'148 # Click //a[normalize-space(.)='资源管理']/img149 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114"):150 with page.expect_navigation():151 page.click("//a[normalize-space(.)='资源管理']/img")152 # Click div[id="subnav_2_15"] >> text="NC管理"153 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114&p=113"):154 # with page.expect_navigation():155 # page.click("div[id=\"subnav_2_15\"] >> text=\"NC管理\"")156 page.goto("https://" + tac + ":8443/admin/main.php?mid=114&p=113")157 # Click a[id="toolbar-add-person"] >> text=/.*添加.*/158 page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")159 # Click //tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']160 page.click("//tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']")161 # Fill //tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']162 page.fill("//tr[normalize-space(.)='名字: *']/td[2]/span/input[1][normalize-space(@type)='text']", ncname + temp2)163 #to do 1.19 //finish 1.21164 # Click //td[normalize-space(.)='--- 11']/span/span/a165 page.click("//td[normalize-space(.)='--- "+ ippoolname +"']/span/span/a")166 # Click //div[2][normalize-space(.)='ip池的名称']167 #1.21——此处的元素顺序是依据IP池创建的顺序加1,若存在多个设置,需要特殊处理168 page.click("//div[2][normalize-space(.)='"+ ippoolname +"']")169 # Click div[id="popup1-buttons"] >> text="保存"170 page.click("div[id=\"popup1-buttons\"] >> text=\"保存\"")171#2021.01.19截至以上均调试完毕172#to do 1.21 // 11:00调试完毕173 with page.expect_navigation():174 page.click("//a[normalize-space(.)='资源管理']/img")175 #page.goto("https://" + tac + ":8443/admin/main.php?mid=114&p=12018")176 # Click text="NC应用"177 # with page.expect_navigation():178 # page.click("text=\"NC应用\"")179 page.goto("https://" + tac + ":8443/admin/main.php?mid=114&p=12018")180 181 # Click a[id="toolbar-add-person"] >> text=/.*添加.*/182 page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")183 # Click //td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']184 page.click("//td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']")185 # Fill //td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']186 page.fill("//td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']", "NC应用")187 # Click //td[2]/div[2]/a[1]/span/span[2][normalize-space(.)=' ']188 page.click("//td[2]/div[2]/a[1]/span/span[2][normalize-space(.)=' ']")189 # Click //td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']190 page.click("//td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']")191 # Fill //td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']192 page.fill("//td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']", "10.92.2.170")193 # Click //td[normalize-space(.)='TCP UDP ICMP ANY   ']/div/span/input[1][normalize-space(@type)='text']194 page.click("//td[normalize-space(.)='TCP UDP ICMP ANY   ']/div/span/input[1][normalize-space(@type)='text']")195 # Fill //td[normalize-space(.)='TCP UDP ICMP ANY   ']/div/span/input[1][normalize-space(@type)='text']196 page.fill("//td[normalize-space(.)='TCP UDP ICMP ANY   ']/div/span/input[1][normalize-space(@type)='text']", "8443")197 # Click //td[2]/a[2]/span[normalize-space(.)='  ']198 page.click("//td[2]/a[2]/span[normalize-space(.)='  ']")199 # Click div[id="bb"] >> text="保存"200 page.click("div[id=\"bb\"] >> text=\"保存\"")201 # assert page.url == "https://" + tac + ":8443/admin/main.php?mid=114&p=12018#"202 # Click //td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']203 page.click("//td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']")204 # Fill //td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']205 page.fill("//td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']", "https://10.92.2.170:8443")206 # Click text="保存"207 page.click("text=\"保存\"")208 with page.expect_navigation():209 page.click("//a[normalize-space(.)='资源管理']/img")210 # Click text="代理应用"211 # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114&p=2012"):212 # with page.expect_navigation():213 # page.click("text=\"代理应用\"")214 page.goto("https://" + tac + ":8443/admin/main.php?mid=114&p=2012")215 # Click a[id="toolbar-add-person"] >> text=/.*添加.*/216 page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")217 # Click //td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']218 page.click("//td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']")219 # Fill //td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']220 page.fill("//td[normalize-space(.)='  *']/span/input[1][normalize-space(@type)='text']", "代理应用")221 # Click //td[2]/div[2]/a[1]/span/span[2][normalize-space(.)=' ']222 page.click("//td[2]/div[2]/a[1]/span/span[2][normalize-space(.)=' ']")223 # Click //td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']224 page.click("//td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']")225 # Fill //td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']226 page.fill("//td[normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']", "10.92.2.250")227 # Click //tr[3]/td[2][normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']228 page.click("//tr[3]/td[2][normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']")229 # Fill //tr[3]/td[2][normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']230 page.fill("//tr[3]/td[2][normalize-space(.)='*']/span/input[1][normalize-space(@type)='text']", "80")231 # Click div[id="bb"] >> text="保存"232 page.click("div[id=\"bb\"] >> text=\"保存\"")233 # assert page.url == "https://" + tac + ":8443/admin/main.php?mid=114&p=2012#"234 # Click //td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']235 page.click("//td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']")236 # Fill //td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']237 page.fill("//td[normalize-space(.)=' ']/span/input[1][normalize-space(@type)='text']", "http://10.92.2.250:80")238 # Click text="保存"239 page.click("text=\"保存\"")240#1.21 11:00 以下待调试241 # Click //a[normalize-space(.)='权限管理']/img242 with page.expect_navigation():243 page.click("//a[normalize-space(.)='权限管理']/img")244 # Click text="授权策略"245 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=115&p=10007"):246 with page.expect_navigation():247 page.click("text=\"授权策略\"")248 # Click a[id="toolbar-add-person"] >> text="添加"249 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=115&p=10008"):250 with page.expect_navigation():251 page.click("a[id=\"toolbar-add-person\"] >> text=\"添加\"")252 # Click //span/input[1][normalize-space(@type)='text']253 page.click("//span/input[1][normalize-space(@type)='text']")254 # Fill //span/input[1][normalize-space(@type)='text']255 page.fill("//span/input[1][normalize-space(@type)='text']", "xue")256 # Click text="编辑"257 page.click("text=\"编辑\"")258 # Check input[name="ck"]259 page.check("input[name=\"ck\"]")260 # Check tr[id="datagrid-row-r3-2-1"] input[name="ck"]261 page.check("tr[id=\"datagrid-row-r3-2-1\"] input[name=\"ck\"]")262 # Check tr[id="datagrid-row-r3-2-2"] input[name="ck"]263 page.check("tr[id=\"datagrid-row-r3-2-2\"] input[name=\"ck\"]")264 # Check tr[id="datagrid-row-r3-2-3"] input[name="ck"]265 page.check("tr[id=\"datagrid-row-r3-2-3\"] input[name=\"ck\"]")266 # Click div[id="popup-resource-buttons"] >> text="确定"267 page.click("div[id=\"popup-resource-buttons\"] >> text=\"确定\"")268 # Click //li[normalize-space(.)='3.用户']269 page.click("//li[normalize-space(.)='3.用户']")270 # Click div[id="entity-subject"] >> text="编辑"271 page.click("div[id=\"entity-subject\"] >> text=\"编辑\"")272 # Click //div[normalize-space(.)='组1612321180054']/span[4]273 page.click("//div[normalize-space(.)='组1612321180054']/span[4]")274 # Click div[id="popup-user-buttons"] >> text="确定"275 page.click("div[id=\"popup-user-buttons\"] >> text=\"确定\"")276 # Click text="保存"277 page.click("text=\"保存\"")278 # Click //div[28]/div[3]/a[1]/span/span[normalize-space(.)='确定']279 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=115&p=10007"):280 with page.expect_navigation():281 page.click("//div[28]/div[3]/a[1]/span/span[normalize-space(.)='确定']")282 # Click //a[normalize-space(.)='认证服务']/img283 with page.expect_navigation():284 page.click("//a[normalize-space(.)='认证服务']/img")285 286 # Click text="认证模块"287 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=1024&p=1025"):288 with page.expect_navigation():289 page.click("text=\"认证模块\"")290 # Click //span/span[normalize-space(.)='奇安信ID']291 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=1024&p=1028&"):292 with page.expect_navigation():293 page.click("//span/span[normalize-space(.)='奇安信ID']")294 # Click form[id="form1"] input[type="text"]295 page.click("form[id=\"form1\"] input[type=\"text\"]")296 # Fill form[id="form1"] input[type="text"]297 page.fill("form[id=\"form1\"] input[type=\"text\"]", "奇安信ID")298 # Go to https://tac:8443/admin/main.php?mid=1024&p=1025299 page.goto("https://tac:8443/admin/main.php?mid=1024&p=1025")300 # Click text="认证策略"301 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=1024&p=1026"):302 with page.expect_navigation():303 page.click("text=\"认证策略\"")304 # Click a[id="toolbar-add-person"] >> text=/.*添加.*/305 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=1024&p=10261"):306 with page.expect_navigation():307 page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")308 # Click input[type="text"]309 page.click("input[type=\"text\"]")310 # Fill input[type="text"]311 page.fill("input[type=\"text\"]", "Agent策略")312 # Fill input[name="app[trigger_method]"]313 page.fill("input[name=\"app[trigger_method]\"]", "0")314 # Go to https://tac:8443/admin/main.php?mid=1024&p=1026315 page.goto("https://tac:8443/admin/main.php?mid=1024&p=1026")316 # Click text="认证门户"317 # with page.expect_navigation(url="https://tac:8443/admin/main.php?mid=1024&p=1024"):318 with page.expect_navigation():319 page.click("text=\"认证门户\"")320 # Click text="PC端默认门户"321 page.click("text=\"PC端默认门户\"")322 # Click //td[normalize-space(.)='默认策略 Agent策略']/span/span/a323 page.click("//td[normalize-space(.)='默认策略 Agent策略']/span/span/a")324 # Click //div[normalize-space(.)='Agent策略']325 page.click("//div[normalize-space(.)='Agent策略']")326 # Click text="保存"327 page.click("text=\"保存\"")328 # Click //div[13]/div[3]/a/span/span[normalize-space(.)='确定']329 page.click("//div[13]/div[3]/a/span/span[normalize-space(.)='确定']")330 # # Go to https://tac:8443/admin/main.php?mid=115&p=10005331 # page.goto("https://" + tac + ":8443/admin/main.php?mid=115&p=10005")332 # # Click a[id="toolbar-add-person"] >> text="添加"333 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=115&p=10006"):334 # with page.expect_navigation():335 # page.click("a[id=\"toolbar-add-person\"] >> text=\"添加\"")336 # # Click //span/input[1][normalize-space(@type)='text']337 # page.click("//span/input[1][normalize-space(@type)='text']")338 # # Fill //span/input[1][normalize-space(@type)='text']339 # page.fill("//span/input[1][normalize-space(@type)='text']", "薛资源")340 # # Go to https://tac:8443/admin/main.php?mid=115&p=10005341 # page.goto("https://" + tac + ":8443/admin/main.php?mid=115&p=10005")342 # # Click text="授权策略"343 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=115&p=10007"):344 # with page.expect_navigation():345 # page.click("text=\"授权策略\"")346 # # Click a[id="toolbar-add-person"] >> text="添加"347 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=115&p=10008"):348 # with page.expect_navigation():349 # page.click("a[id=\"toolbar-add-person\"] >> text=\"添加\"")350 # # Click //span/input[1][normalize-space(@type)='text']351 # page.click("//span/input[1][normalize-space(@type)='text']")352 # # Fill //span/input[1][normalize-space(@type)='text']353 # page.fill("//span/input[1][normalize-space(@type)='text']", "薛授权策略")354 # # Go to https://tac:8443/admin/main.php?mid=115&p=10007355 # page.goto("https://" + tac + ":8443/admin/main.php?mid=115&p=10007")356 # # Click text="认证门户"357 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=1024"):358 # with page.expect_navigation():359 # page.click("text=\"认证门户\"")360 # # Click a[id="toolbar-add-person"] >> text=/.*添加.*/361 # page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")362 # # Click text=/.*输入门户名字.*/ >> input[type="text"]363 # page.click("text=/.*输入门户名字.*/ >> input[type=\"text\"]")364 # # Fill text=/.*输入门户名字.*/ >> input[type="text"]365 # page.fill("text=/.*输入门户名字.*/ >> input[type=\"text\"]", "薛路由门户")366 # # Go to https://tac:8443/admin/main.php?mid=1024&p=1032367 # page.goto("https://" + tac + ":8443/admin/main.php?mid=1024&p=1032")368 # # Click a[id="toolbar-add-person"] >> text=/.*添加.*/369 # page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")370 # # Click form[id="form1"] input[type="text"]371 # page.click("form[id=\"form1\"] input[type=\"text\"]")372 # # Fill form[id="form1"] input[type="text"]373 # page.fill("form[id=\"form1\"] input[type=\"text\"]", "薛路由门户的路由")374 # # Fill //tr[normalize-space(.)='域名:     域名']/td[2]/span/input[1][normalize-space(@type)='text']375 # page.fill("//tr[normalize-space(.)='域名:     域名']/td[2]/span/input[1][normalize-space(@type)='text']", "rzdoor.com")376 # # Go to https://tac:8443/admin/main.php?mid=1024&p=1024377 # page.goto("https://" + tac + ":8443/admin/main.php?mid=1024&p=1024")378 # # Click text="薛路由门户"379 # page.click("text=\"薛路由门户\"")380 # # Click //span/a381 # page.click("//span/a")382 # # Click //td[normalize-space(.)='默认策略']383 # page.click("//td[normalize-space(.)='默认策略']")384 # # Click text="保存"385 # page.click("text=\"保存\"")386 # # Click //div[13]/div[3]/a/span/span[normalize-space(.)='确定']387 # page.click("//div[13]/div[3]/a/span/span[normalize-space(.)='确定']")388 # # Click text="认证策略"389 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=1026"):390 # with page.expect_navigation():391 # page.click("text=\"认证策略\"")392 # # Click a[id="toolbar-add-person"] >> text=/.*添加.*/393 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=10261"):394 # with page.expect_navigation():395 # page.click("a[id=\"toolbar-add-person\"] >> text=/.*添加.*/")396 # # Click input[type="text"]397 # page.click("input[type=\"text\"]")398 # # Fill input[type="text"]399 # page.fill("input[type=\"text\"]", "薛路由门户的认证策略")400 # # Fill input[name="app[trigger_method]"]401 # page.fill("input[name=\"app[trigger_method]\"]", "0")402 # # Click //span[normalize-space(.)='多因子']/em403 # page.frame(url="https://" + tac + ":8443/admin/aas/views/mfa_rules.php?id=0").click("//span[normalize-space(.)='多因子']/em")404 # # Click text=/.*取消.*/405 # page.frame(url="https://" + tac + ":8443/admin/aas/views/mfa_rules.php?id=0").click("text=/.*取消.*/")406 # # Go to https://tac:8443/admin/main.php?mid=1024&p=1026407 # page.goto("https://" + tac + ":8443/admin/main.php?mid=1024&p=1026")408 # # Click text="认证模块"409 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=1025"):410 # with page.expect_navigation():411 # page.click("text=\"认证模块\"")412 # # Click //span/span[normalize-space(.)='奇安信ID']413 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=1028&"):414 # with page.expect_navigation():415 # page.click("//span/span[normalize-space(.)='奇安信ID']")416 # # Click form[id="form1"] input[type="text"]417 # page.click("form[id=\"form1\"] input[type=\"text\"]")418 # # Fill form[id="form1"] input[type="text"]419 # page.fill("form[id=\"form1\"] input[type=\"text\"]", "奇安信ID")420 # # Go to https://tac:8443/admin/main.php?mid=1024&p=1026421 # page.goto("https://" + tac + ":8443/admin/main.php?mid=1024&p=1026")422 # # Click text="薛路由门户的认证策略"423 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=10261&id=2"):424 # with page.expect_navigation():425 # page.click("text=\"薛路由门户的认证策略\"")426 # # Click //td[normalize-space(.)='奇安信ID']/span/span/a427 # page.click("//td[normalize-space(.)='奇安信ID']/span/span/a")428 # # Click //div[6]/div/div[normalize-space(.)='奇安信ID']429 # page.click("//div[6]/div/div[normalize-space(.)='奇安信ID']")430 # # Click text="保存"431 # page.click("text=\"保存\"")432 # # Go to https://tac:8443/admin/main.php?mid=1024&p=1026433 # page.goto("https://" + tac + ":8443/admin/main.php?mid=1024&p=1026")434 # # Click text="认证门户"435 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=1024&p=1024"):436 # with page.expect_navigation():437 # page.click("text=\"认证门户\"")438 # # Click text="薛路由门户"439 # page.click("text=\"薛路由门户\"")440 # # Click //span/a441 # page.click("//span/a")442 # # Click //div[normalize-space(.)='薛路由门户的认证策略']443 # page.click("//div[normalize-space(.)='薛路由门户的认证策略']")444 # # Click //div[5]/div[3]/a[1]/span/span[2][normalize-space(.)=' ']445 # page.click("//div[5]/div[3]/a[1]/span/span[2][normalize-space(.)=' ']")446 # # Click //div[13]/div[3]/a/span/span[normalize-space(.)='确定']447 # page.click("//div[13]/div[3]/a/span/span[normalize-space(.)='确定']")448 # # Click text="可信代理管理"449 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=11&p=2002"):450 # with page.expect_navigation():451 # page.click("text=\"可信代理管理\"")452 # # Click text="资源管理"453 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114"):454 # with page.expect_navigation():455 # page.click("text=\"资源管理\"")456 # # Click text=/.*同步到可信代理.*/457 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=11&p=2007&op=sync&push_type=wag"):458 # with page.expect_navigation():459 # page.click("text=/.*同步到可信代理.*/")460 # # Click //div[8]/div[3]/a[1]/span/span[2][normalize-space(.)=' ']461 # page.click("//div[8]/div[3]/a[1]/span/span[2][normalize-space(.)=' ']")462 # # Go to https://tac:8443/admin/main.php?mid=11&p=2007463 # page.goto("https://" + tac + ":8443/admin/main.php?mid=11&p=2007")464 # # Click text="NC应用"465 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114&p=12018"):466 # with page.expect_navigation():467 # page.click("text=\"NC应用\"")468 # # Click text=/.*同步到可信代理.*/469 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=11&p=2007&op=sync&push_type=l3_proxy"):470 # with page.expect_navigation():471 # page.click("text=/.*同步到可信代理.*/")472 # # Click a[id="push_save_btn"] >> text="保存"473 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=11&p=2007"):474 # with page.expect_navigation():475 # page.click("a[id=\"push_save_btn\"] >> text=\"保存\"")476 # # Click text="代理应用"477 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=114&p=2012"):478 # with page.expect_navigation():479 # page.click("text=\"代理应用\"")480 # # Click text=/.*同步到可信代理.*/481 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=11&p=2007&op=sync&push_type=l4_proxy"):482 # with page.expect_navigation():483 # page.click("text=/.*同步到可信代理.*/")484 # # Click a[id="push_save_btn"] >> text="保存"485 # # with page.expect_navigation(url="https://" + tac + ":8443/admin/main.php?mid=11&p=2007"):486 # with page.expect_navigation():487 # page.click("a[id=\"push_save_btn\"] >> text=\"保存\"")488 # # Close page489 # page.close()490 # ---------------------491 context.close()492 browser.close()493with sync_playwright() as playwright:...

Full Screen

Full Screen

commerce.py

Source:commerce.py Github

copy

Full Screen

...13 page.click(":nth-match([data-testid=\"categoryButton\"], 2)")14 # Click [data-testid="categoryButton"]15 page.click("[data-testid=\"categoryButton\"]")16 # Click text=Jackets17 # with page.expect_navigation(url="https://demo.vuestorefront.io/men/tops-men/jackets-men.html"):18 with page.expect_navigation():19 page.click("text=Jackets")20 # Click :nth-match(img[alt="Montana Wind Jacket"], 3)21 # with page.expect_navigation(url="https://demo.vuestorefront.io/montana-wind-jacket.html?childSku=MJ03-XS-Black"):22 with page.expect_navigation():23 page.click(":nth-match(img[alt=\"Montana Wind Jacket\"], 3)")24 # Click [aria-label="Select color Green"]25 page.click("[aria-label=\"Select color Green\"]")26 # assert page.url == "https://demo.vuestorefront.io/montana-wind-jacket.html?childSku=MJ03-XS-Green"27 # Click [aria-label="Select size M"]28 page.click("[aria-label=\"Select size M\"]")29 # assert page.url == "https://demo.vuestorefront.io/montana-wind-jacket.html?childSku=MJ03-M-Green"30 # Click [data-testid="addToCart"]31 page.click("[data-testid=\"addToCart\"]")32 # Click [data-testid="notificationAction1"]33 page.click("[data-testid=\"notificationAction1\"]")34 # insert to scroll up35 page.mouse.wheel(0, -1000)36 # Click [data-testid="openMicrocart"]37 page.click("[data-testid=\"openMicrocart\"]")38 # Click [data-testid="subscribeSubmit"]39 # with page.expect_navigation(url="https://demo.vuestorefront.io/checkout"):40 with page.expect_navigation():41 page.click("[data-testid=\"subscribeSubmit\"]")42 # Click input[name="first-name"]43 page.click("input[name=\"first-name\"]")44 # Fill input[name="first-name"]45 page.fill("input[name=\"first-name\"]", "steve")46 # Press Tab47 page.press("input[name=\"first-name\"]", "Tab")48 # Fill input[name="last-name"]49 page.fill("input[name=\"last-name\"]", "steve")50 # Press Tab51 page.press("input[name=\"last-name\"]", "Tab")52 # Fill input[name="email-address"]53 page.fill("input[name=\"email-address\"]", "steve@email.com")54 # Click [data-testid="personalDetailsSubmit"]...

Full Screen

Full Screen

mytest.py

Source:mytest.py Github

copy

Full Screen

...12 page.click("text=\"Email, phone, or Skype\"")13 # Fill input[aria-label="Enter your email, phone, or Skype."]14 page.fill("input[aria-label=\"Enter your email, phone, or Skype.\"]", "hacker2okb@OTAPRD1485ops.onmicrosoft.com")15 # Click input[type="submit"]16 # with page.expect_navigation(url="https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id=c44b4083-3bb0-49c1-b47d-974e53cbdf3c&response_type=code%20id_token&scope=https%3A%2F%2Fmanagement.core.windows.net%2F%2Fuser_impersonation%20openid%20email%20profile&state=OpenIdConnect.AuthenticationProperties%3DMKbcSxSTICoJN1kt8D5nwvx9SQt4QkVloIDY3FogjShP6o_PQ6ehfTftIxtWpZPXMegc0nuD_uimxQ_93rRQuyPH_xyF-LYgzMBHonwKVldvLp8FCf-DIdApaWzkSRDl2V2-tzUHgSev-RcYdWHOYLak9wMqKlz1XhkgN2FN6dA-gqypCUwK56oYuxxpJhYAnqr17qKSf_SCHhJfc7_knLGbJuxMbwnPsTlc4eep8JEsQALkDnm-x3uIp0leonCFdT95bg8k0PEm0nw0YTUtfelqU90AMvtrW87J4njKceFydEE48q4ecTfSduLK-lnm2bsJ2jlNjfbe16fPD4_2n0kkoDc3nj_26Xvadyk78mtjDn0AAelkC3h_JwLdOwQk&response_mode=form_post&nonce=637426179104629098.Mzc3MjE4MjQtZGUzZC00ZjdlLWJkZjEtMDljNzhmNjljM2NlMjczNmQ3MDctZWM1My00YmYzLTg0NzktNWYzYTIyNzdmY2Qy&redirect_uri=https%3A%2F%2Fportal.azure.com%2Fsignin%2Findex%2F&site_id=501430&client-request-id=d9c101d6-d381-4640-a8af-7b643cee945d&x-client-SKU=ID_NET45&x-client-ver=5.3.0.0"):17 with page.expect_navigation():18 page.click("input[type=\"submit\"]")19 # Click text="Password"20 page.click("text=\"Password\"")21 # Fill input[aria-label="Enter the password for hacker2okb@otaprd1485ops.onmicrosoft.com"]22 page.fill("input[aria-label=\"Enter the password for hacker2okb@otaprd1485ops.onmicrosoft.com\"]", "QZiO$*CTQPQ5")23 # Click input[type="submit"]24 # with page.expect_navigation(url="https://login.microsoftonline.com/common/login"):25 with page.expect_navigation():26 page.click("input[type=\"submit\"]")27 # Click input[type="submit"]28 # with page.expect_navigation(url="https://portal.azure.com/#home"):29 with page.expect_navigation():30 page.click("input[type=\"submit\"]")31 # Click text="Virtual machines"32 page.click("text=\"Virtual machines\"")33 # assert page.url() == "https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Compute%2FVirtualMachines"34 # Close page35 page.close()36 # ---------------------37 context.close()38 browser.close()39with sync_playwright() as playwright:...

Full Screen

Full Screen

login.py

Source:login.py Github

copy

Full Screen

...10 page.goto("https://platform.grid.ai/#/")11 # Go to https://platform.grid.ai/#/landing12 page.goto("https://platform.grid.ai/#/landing")13 # Click img[alt="Google"]14 # with page.expect_navigation(url="https://accounts.google.com/o/oauth2/auth/identifier?after_auth_default_redirect=%2F&scope=profile%20email&redirect_uri=https%3A%2F%2Fplatform.grid.ai%2Foauth&client_id=438065754791-at0f2q42fr7dvnbggs2uj5l275enre7p.apps.googleusercontent.com&response_type=code&flowName=GeneralOAuthFlow"):15 with page.expect_navigation():16 page.click("img[alt=\"Google\"]")17 # assert page.url == "https://accounts.google.com/o/oauth2/auth?after_auth_default_redirect=%2F&scope=profile+email&redirect_uri=https%3A%2F%2Fplatform.grid.ai%2Foauth&client_id=438065754791-at0f2q42fr7dvnbggs2uj5l275enre7p.apps.googleusercontent.com&response_type=code"18 # Click [aria-label="Email or phone"]19 page.click("[aria-label=\"Email or phone\"]")20 # Fill [aria-label="Email or phone"]21 page.fill("[aria-label=\"Email or phone\"]", "sangkyulee@gmail.com")22 # Click button:has-text("Next")23 # with page.expect_navigation(url="https://accounts.google.com/signin/v2/challenge/pwd?after_auth_default_redirect=%2F&scope=profile%20email&redirect_uri=https%3A%2F%2Fplatform.grid.ai%2Foauth&client_id=438065754791-at0f2q42fr7dvnbggs2uj5l275enre7p.apps.googleusercontent.com&response_type=code&flowName=GeneralOAuthFlow&cid=1&navigationDirection=forward&TL=AM3QAYYfygCHv4k-6WHieGyWtrKg5mRX7giwapTh0EhJuENQIay3DUxcYYp8OU5k"):24 with page.expect_navigation():25 page.click("button:has-text(\"Next\")")26 # Click [aria-label="Enter your password"]27 page.click("[aria-label=\"Enter your password\"]")28 # Fill [aria-label="Enter your password"]29 page.fill("[aria-label=\"Enter your password\"]", "Spm3mw5cgSpm3mw5cr")30 # Click button:has-text("Next")31 page.click("button:has-text(\"Next\")")32 # assert page.url == "https://accounts.google.com/signin/v2/challenge/pwd?after_auth_default_redirect=%2F&scope=profile%20email&redirect_uri=https%3A%2F%2Fplatform.grid.ai%2Foauth&client_id=438065754791-at0f2q42fr7dvnbggs2uj5l275enre7p.apps.googleusercontent.com&response_type=code&flowName=GeneralOAuthFlow&cid=1&navigationDirection=forward&TL=AM3QAYYfygCHv4k-6WHieGyWtrKg5mRX7giwapTh0EhJuENQIay3DUxcYYp8OU5k"33 # Fill [aria-label="Enter your password"]34 page.fill("[aria-label=\"Enter your password\"]", "Spm3mw5cgSpm3mw5co")35 # Click button:has-text("Next")36 # with page.expect_navigation(url="https://platform.grid.ai/#/"):37 with page.expect_navigation():38 page.click("button:has-text(\"Next\")")39 # assert page.url == "https://accounts.google.com/signin/v2/challenge/pwd?after_auth_default_redirect=%2F&scope=profile%20email&redirect_uri=https%3A%2F%2Fplatform.grid.ai%2Foauth&client_id=438065754791-at0f2q42fr7dvnbggs2uj5l275enre7p.apps.googleusercontent.com&response_type=code&flowName=GeneralOAuthFlow&cid=1&navigationDirection=forward&TL=AM3QAYYfygCHv4k-6WHieGyWtrKg5mRX7giwapTh0EhJuENQIay3DUxcYYp8OU5k"40 # Go to https://platform.grid.ai/#/dashboard41 page.goto("https://platform.grid.ai/#/dashboard")42 # ---------------------43 context.storage_state(path="auth.json")44 context.close()45 browser.close()46with sync_playwright() as playwright:...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful