按钮的Find and click()函数

2024-09-30 02:30:52 发布

您现在位置:Python中文网/ 问答频道 /正文

对于以下检查,我无法单击“MARK WebAttention”按钮

<div class="box1child" ng-show="markAttendance"><button ng-show="showMarkAttendance"  style="background-color:#398439;">MARK ATTENDANCE</button></div>
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Ie()


driver.get("https:*********/WebAttendance/index.html")

mark_webattendance = driver.find_element_by_xpath("//button[@ng-show='showMarkAttendance']")
mark_webattendance.click()

Tags: fromimportdivbydriverseleniumshowbutton
3条回答

访问按钮的方式-

var element = driver.find_element_by_xpath("//button[@id ='kk' and text()='MARK ATTENDANCE']");
driver.implicitly_wait(10000);
element.click();

var element = driver.find_element_by_xpath("//button[text()='MARK ATTENDANCE']");
driver.implicitly_wait(10000);
element.click();

var element = driver.find_element_by_xpath("//button[contains(text(), 'MARK ATTENDANCE')]");
driver.implicitly_wait(10000);
element.click();

马克•韦伯=driver.find\元素\u by\ xpath(“//按钮[包含(text(),'标记考勤')]”) driver.implicit\u等待(10000) 标记_webattention.click网站()

xpath的用法是//tagName[@attribute = 'value']这是为了精确匹配 //tagName[contains(text(), 'value')]这是用于包含值的字符串 另一个选项是//tagName[contains(@attribute, 'value')]

相关问题 更多 >

    热门问题