[英]How can i click the element on webpage using selenium with python
HTML信息是:
<a title="Create an Account" class="button" href="http://demo.magentocommerce.com/customer/account/create/"> <span> <span>Create an Account </span> </span> </a>
創建一個帳戶
我正在嘗試:
create_account_button = driver.find_element_by_xpath("//button[@title='Create an Account']")
create_account_button.click()
但它不起作用
實際上分配了WebElement變量,您使用以下代碼
WebElement button = driver.findElement(By.xpath("//a[@title='Create an Account']");
button.click();
腳步
WebElement
變量按鈕並為其分配值。 click()
對於Java,請按照上述步驟操作,對於Python,請按照以下步驟操作
driver.find_element_by_xpath('//a[@title='Create an Account']').click()
您需要使用的Xpath在<a>
而不在<button>
因此,請嘗試使用此Xpath //a[@title='Create an Account']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.