<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Phantom Wallet</title>
<style>
@font-face {
font-family: Circular;
font-style: normal;
font-weight: 700;
src: url(/Circular-Bold.ab51009b.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 400;
src: url(/Inter-Regular.f744dc98.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: italic;
font-weight: 400;
src: url(/Inter-Italic.cc99ad32.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 500;
src: url(/Inter-Medium.54afb6d9.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: italic;
font-weight: 500;
src: url(/Inter-MediumItalic.15785acc.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 600;
src: url(/Inter-SemiBold.8bc2ab1d.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: italic;
font-weight: 600;
src: url(/Inter-SemiBoldItalic.a1bdb746.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 700;
src: url(/Inter-Bold.e46cc865.woff) format("woff")
}
@font-face {
font-family: Inter;
font-style: italic;
font-weight: 700;
src: url(/Inter-BoldItalic.7c23f14e.woff) format("woff")
}
</style>
<link rel="stylesheet" href="/onboarding.6e49cdaa.css">
<style></style>
<style></style>
<style data-styled="active" data-styled-version="5.3.3"></style>
<script async="" type="text/javascript" charset="utf-8" src="chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/module.3cd8ded6.js"></script>
<script async="" type="text/javascript" charset="utf-8" src="chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/src.e7d44f0a.js"></script>
</head>
<body> <noscript>You need to enable Javascript to run this application.</noscript>
<div id="root">
<header class="sc-iCfMLu jjkbpo">
<div class="sc-furwcr fMVITX"><img src="/grey_logo.bc329f22.png" width="22px">
<div class="sc-pVTFL cxKcap">
<p size="16" opacity="1" color="white" class="sc-eCImPb sc-gKclnd ibvLmR bEOvQm">Phantom</p>
<p size="15" color="#8A81F8" opacity="1" class="sc-eCImPb ksZaoi">Бета!</p>
</div>
</div><a href="https://help.phantom.app" rel="noopener" target="_blank" class="sc-jrQzAO cfqufO"><svg width="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.5 0C3.3589 0 0 3.3589 0 7.5C0 11.6411 3.3589 15 7.5 15C11.6411 15 15 11.6411 15 7.5C15 3.3589 11.6411 0 7.5 0ZM8.31288 11.7485C8.31288 12.0092 8.09816 12.2239 7.83742 12.2239H6.62577C6.36503 12.2239 6.15031 12.0092 6.15031 11.7485V10.9663C6.15031 10.7055 6.36503 10.4908 6.62577 10.4908H7.83742C8.09816 10.4908 8.31288 10.7055 8.31288 10.9663V11.7485ZM10.2301 7.08589C9.90798 7.53067 9.5092 7.88344 9.0184 8.14417C8.74233 8.32822 8.55828 8.51227 8.46626 8.72699C8.40491 8.86503 8.3589 9.04908 8.32822 9.2638C8.31288 9.43252 8.15951 9.55521 7.9908 9.55521H6.50307C6.30368 9.55521 6.15031 9.3865 6.16564 9.20245C6.19632 8.78834 6.30368 8.46626 6.47239 8.22086C6.68712 7.92945 7.07055 7.57669 7.6227 7.19325C7.91411 7.0092 8.12883 6.79448 8.29755 6.53374C8.46626 6.27301 8.54294 5.96626 8.54294 5.6135C8.54294 5.26074 8.45092 4.96932 8.25153 4.7546C8.05215 4.53988 7.79141 4.43252 7.43865 4.43252C7.14724 4.43252 6.91718 4.52454 6.71779 4.69325C6.59509 4.80061 6.5184 4.93865 6.47239 5.1227C6.41104 5.33742 6.21166 5.47546 5.98159 5.47546L4.60123 5.44479C4.43252 5.44479 4.29448 5.29141 4.30982 5.1227C4.35583 4.3865 4.64724 3.83436 5.15337 3.43558C5.7362 2.9908 6.48773 2.76074 7.43865 2.76074C8.45092 2.76074 9.24847 3.02147 9.83129 3.52761C10.4141 4.03374 10.7055 4.72393 10.7055 5.59816C10.7055 6.15031 10.5368 6.6411 10.2301 7.08589Z"></path></svg><p color="#AAA" size="16" opacity="1" class="sc-eCImPb ZGBkn">Помощь</p></a></header>
<main
class="sc-kMyqmI dXIMBC">
<div style="height: 100%; opacity: 1; transform: none;">
<div class="sc-wkwDy cfHEYF">
<div class="sc-bjztik sc-kszsFN lcQfhY hZUhSR"><svg width="94" viewBox="0 0 102 102" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#filter0_d)"><circle cx="51" cy="49" r="47" fill="url(#paint0_linear)"></circle></g><g filter="url(#filter1_d)"><path d="M84.647 49.5727H76.3615C76.3615 32.6875 62.6254 19 45.6802 19C28.9446 19 15.3384 32.3524 15.0054 48.9484C14.6609 66.1032 30.8127 81 48.0309 81H50.1966C65.3766 81 85.7225 69.1593 88.9012 54.732C89.4883 52.0725 87.3801 49.5727 84.647 49.5727ZM33.3673 50.3249C33.3673 52.5829 31.514 54.4296 29.248 54.4296C26.9819 54.4296 25.1286 52.5821 25.1286 50.3249V43.6843C25.1286 41.4263 26.9819 39.5795 29.248 39.5795C31.514 39.5795 33.3673 41.4263 33.3673 43.6843V50.3249ZM47.6716 50.3249C47.6716 52.5829 45.8183 54.4296 43.5522 54.4296C41.2862 54.4296 39.4329 52.5821 39.4329 50.3249V43.6843C39.4329 41.4263 41.287 39.5795 43.5522 39.5795C45.8183 39.5795 47.6716 41.4263 47.6716 43.6843V50.3249Z" fill="url(#paint1_linear)"></path></g><defs><filter id="filter0_d" x="0" y="0" width="102" height="102" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset dy="2"></feOffset><feGaussianBlur stdDeviation="2"></feGaussianBlur><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"></feBlend></filter><filter id="filter1_d" x="7" y="11" width="90" height="78" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"></feColorMatrix><feOffset></feOffset><feGaussianBlur stdDeviation="4"></feGaussianBlur><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"></feBlend></filter><linearGradient id="paint0_linear" x1="51" y1="2" x2="51" y2="96" gradientUnits="userSpaceOnUse"><stop stop-color="#534BB1"></stop><stop offset="1" stop-color="#551BF9"></stop></linearGradient><linearGradient id="paint1_linear" x1="52" y1="19" x2="52" y2="81" gradientUnits="userSpaceOnUse"><stop stop-color="white"></stop><stop offset="1" stop-color="white" stop-opacity="0.82"></stop></linearGradient></defs></svg>
<svg
width="166" height="32" viewBox="0 0 166 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.04 14.914V5.67404H10.29C13.482 5.67404 15.414 7.48004 15.414 10.336C15.414 13.15 13.482 14.914 10.29 14.914H5.04ZM11.046 19.366C16.758 19.366 20.538 15.544 20.538 10.294C20.538 5.08604 16.758 1.22204 11.046 1.22204H0V31H5.04V19.366H11.046Z"
fill="white"></path>
<path d="M29.3895 18.988C29.4735 16.384 30.9435 14.368 33.6315 14.368C36.6975 14.368 37.8315 16.384 37.8315 18.904V31H42.7035V18.064C42.7035 13.57 40.2675 9.95804 35.2275 9.95804C33.0855 9.95804 30.7755 10.714 29.3895 12.52V0.592041H24.5175V31H29.3895V18.988Z"
fill="white"></path>
<path d="M47.3747 25.456C47.3747 28.69 50.0207 31.63 54.3047 31.63C57.6227 31.63 59.6387 29.95 60.6047 28.396C60.6047 30.034 60.7727 30.874 60.8147 31H65.3507C65.3087 30.79 65.0987 29.572 65.0987 27.724V17.56C65.0987 13.486 62.7047 9.91604 56.4047 9.91604C51.3647 9.91604 48.1727 13.066 47.7947 16.594L52.2467 17.602C52.4567 15.544 53.8847 13.906 56.4467 13.906C59.1347 13.906 60.3107 15.292 60.3107 17.014C60.3107 17.728 59.9747 18.316 58.7987 18.484L53.5487 19.282C50.0627 19.786 47.3747 21.802 47.3747 25.456ZM55.2287 27.808C53.2967 27.808 52.2467 26.548 52.2467 25.162C52.2467 23.482 53.4647 22.642 54.9767 22.39L60.3107 21.592V22.516C60.3107 26.506 57.9587 27.808 55.2287 27.808Z"
fill="white"></path>
<path d="M75.8602 19.198C75.8602 16.51 77.3302 14.368 80.1022 14.368C83.1682 14.368 84.3022 16.384 84.3022 18.904V31H89.1742V18.064C89.1742 13.57 86.7802 9.95804 81.7822 9.95804C79.5142 9.95804 77.0782 10.924 75.7342 13.276V10.546H70.9882V31H75.8602V19.198Z"
fill="white"></path>
<path d="M101.279 4.28804H96.8694V7.35404C96.8694 9.16004 95.9034 10.546 93.7194 10.546H92.6694V14.872H96.4494V25.162C96.4494 28.984 98.8014 31.252 102.581 31.252C104.345 31.252 105.269 30.916 105.563 30.79V26.758C105.353 26.8 104.555 26.926 103.883 26.926C102.077 26.926 101.279 26.17 101.279 24.364V14.872H105.521V10.546H101.279V4.28804Z"
fill="white"></path>
<path d="M119.31 27.262C116.328 27.262 113.598 24.994 113.598 20.752C113.598 16.51 116.328 14.326 119.31 14.326C122.334 14.326 125.022 16.51 125.022 20.752C125.022 25.036 122.334 27.262 119.31 27.262ZM119.31 9.91604C113.22 9.91604 108.726 14.494 108.726 20.752C108.726 27.052 113.22 31.63 119.31 31.63C125.442 31.63 129.936 27.052 129.936 20.752C129.936 14.494 125.442 9.91604 119.31 9.91604Z"
fill="white"></path>
<path d="M139.474 31V18.862C139.474 16.258 141.112 14.326 143.716 14.326C146.488 14.326 147.664 16.174 147.664 18.526V31H152.452V18.862C152.452 16.342 154.132 14.326 156.694 14.326C159.424 14.326 160.642 16.132 160.642 18.526V31H165.346V17.728C165.346 12.31 161.818 9.95804 158.122 9.95804C155.476 9.95804 153.082 10.882 151.486 13.57C150.394 11.176 148.042 9.95804 145.354 9.95804C143.044 9.95804 140.482 11.05 139.306 13.15V10.546H134.644V31H139.474Z"
fill="white"></path>
</svg>
<p color="#999" size="17" opacity="1" class="sc-eCImPb bhSIuT">Новый взгляд на криптокошелек для DeFi и NFT</p>
</div>
<section class="sc-cBIieI ciUlFM"><button font-size="16" font-weight="600" width="100%" type="button" class="sc-bdvvtL jdiDvS">Создать новый кошелек</button><button font-size="16" font-weight="600" width="100%" type="button" class="sc-bdvvtL ljDDId">Использовать секретную фразу</button></section>
</div>
</div>
</main>
</div>
<script src="/onboarding.6e49cdaa.js"></script>
</body>
</html>
我試圖在 webdriver 上安裝擴展并打開簽名頁面后自動登錄 Phantom 錢包,但無論我如何嘗試查找按鈕元素,selenium 都會引發錯誤。我什至添加了 webdriver 等待功能,但它沒有幫助。
這是我的代碼:
import os
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import eden_ab.constants as const
from selenium import webdriver
os.environ['PATH'] = const.DRIVER_PATH #valid driver path
#adding Phantom extension and launching driver
chop = webdriver.ChromeOptions()
chop.add_extension("res/Phantom 0.14.1.0.crx")
driver = webdriver.Chrome(options=chop)
driver.implicitly_wait(5)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'sc-bdvvtL ljDDId'))) #here is where the error occures after wait timeout
phantom_signin = driver.find_element('sc-bdvvtL ljDDId')
phantom_signin.click
此代碼引發以下錯誤:
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'sc-bdvvtL ljDDId')))
這是我試圖點擊擴展板載頁面的灰色按鈕:
chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/onboarding.html
更新:如果我洗掉 webdriver wait 它會引發此錯誤
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid locator
uj5u.com熱心網友回復:
該錯誤是不言自明的:
find_element 不能這樣作業:
phantom_signin = driver.find_element('sc-bdvvtL ljDDId')
相反,它應該是:
phantom_signin = driver.find_element_by_css_selector('.sc-bdvvtL.ljDDId')
或者
phantom_signin = driver.find_element(By.CSS_SELECTOR, ".sc-bdvvtL.ljDDId")
in系結sc-bdvvtL ljDDId不支持具有這樣名稱的類,因為我們不支持空格,您可以洗掉空格并放置 a來制作 a 。CLASS_NAMESelenium Python.CSS selector
更新:
我確實看到該類在本質上是獨一無二的,但這并不是整個 HTML 的樣子。您可以嘗試使用 belox XPath:
//button[text()='Использовать секретную фразу']
并像這樣單擊它:
代碼試用一:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Использовать секретную фразу']"))).click()
進口:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
uj5u.com熱心網友回復:
sc-bdvvtL ljDDId實際上包含2個類名。
為了匹配這個元素,你可以使用這個 css_selector
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '.sc-bdvvtL.ljDDId')))
或者放一個點而不是仍然使用的.空間: By.CLASS_NAME
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'sc-bdvvtL.ljDDId')))
uj5u.com熱心網友回復:
我找到了解決方案!謝謝大家幫忙!
發生錯誤是因為載入鏈接是由瀏覽器打開的,而不是 selenium,因此您需要首先關注此視窗
固定代碼:
import os
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import eden_ab.constants as const
from selenium import webdriver
os.environ['PATH'] = const.DRIVER_PATH
chop = webdriver.ChromeOptions()
chop.add_extension("res/Phantom 0.14.1.0.crx")
driver = webdriver.Chrome(options=chop)
driver.implicitly_wait(5)
driver.get('chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/onboarding.html')
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Использовать секретную фразу']"))).click()
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/414629.html
標籤:
