仅当包含"买入"或"卖出"时单击"多值选项卡"按钮



我试图点击tabbed button,如果它被设置为Buy or Sell

基本检测选项卡按钮中Buy or Sell标志是否设置

买卖选项卡按钮在URL Kraken

基本上检测disabled="">Buy<是否表示购买,如果是,则单击按钮

或者如果disabled="">Sell<显示Sell,则单击按钮

点击"购买"后,代码变为:

<button class="_1_R9vNUDdcou2Z7JyNUxJO _2L9SQFRN3bCg-05kS6dcFn" tabindex="0" disabled="">Buy</button>
<button class="_1_R9vNUDdcou2Z7JyNUxJO" tabindex="0">Sell</button>

我使用的代码:

driver.find_element_by_xpath("//button[@class='_1_R9vNUDdcou2Z7JyNUxJO']").click()

谢谢!

我想这应该可以。

#locate the button
button=driver.find_element_by_xpath("//button[@class='_1_R9vNUDdcou2Z7JyNUxJO']")
#get button text
button_text=button.text
#find attribute(disabled) value for the button
button_disabled=button.get_attribute("disabled")
#if button text=Buy or Sell and button disabled value="" click the button
if (button_text=='Sell' and button_disabled=="") or (button_text=='Buy' and button_disabled==""):
button.click()

最新更新