当未显示 xpath 时,我试图停止 while 循环。但是,代码以一条NoSuchElementException消息停止。这是我的代码, n=1 while n<100: n+=1 time.sleep(10)# Data=driver.find_element_by_xpath('.//tbody//tr//td//span//a[text() != ""]').is_displayed() if Data == True: ... if Data == False: break 但我得到:“NoSuchElementException:消息:没有这样的元素:无法定位元素:{"method":"xpath","selector":".//tbody//tr//td//span//a[text() != ""]"}"这正是我想停止循环的时候……当元素无法定位时。
添加回答
举报
0/150
提交
取消