In advance I apologize for my English, because I write with an interpreter.
There is a task to click on one of these accounts, suppose AAccount, using Selenium Web Driver (Python, Chrome).
The problem is that it's impossible to do this on XPath and CSS, because the elements are the same.
Here is part of the source code for the page. I also attached a screenshot of the page.
</style>
</head>
<body>
<div class="wrapper">
<div class="gb_ag" ng-non-bindable="" id="gb"><div class="gb_hf gb_fg"><div class="gb_ib gb_fg gb_R gb_eg"><div class="gb_7d gb_R gb_fg gb_7f"><div class="gb_Q gb_R gb_S gb_fg"><span class="gb_P gb_R">TeAOK</span></div></div><div class="gb_sc gb_fg gb_R"><div class="gb_ga" id="gbsfw" style="background-color:#eee;min-width:376px"></div><div class="gb_Ac gb_Wc gb_R gb_Bc"><div class="gb_Dc"><a class="gb_b" aria-haspopup="true" role="button" tabindex="0"><div class="gb_Ec gb_Fc gb_4b"></div></a><div class="gb_lb"></div><div class="gb_kb" style="border-bottom-color:#eee"></div></div><div class="gb_ga" aria-hidden="true" aria-live="assertive"></div></div><div class="gb_fb gb_Wc gb_fg gb_R"><div class="gb_Dc gb_hb gb_fg gb_R"><a class="gb_b gb_db gb_R" href="https://accounts.google.com/SignOutOptions?hl=ru&continue=https://accounts.google.com/b/0/DelegateAccountSelector%3Fcontinue%3Dhttps%253A%252F%252Faccounts.google.com%252Fo%252Foauth2%252Fauth%253Fclient_id%253D702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com%2526redirect_uri%253Dhttps%253A%252F%252Fvkmix.com%252Fmodules%252Fyoutube%252Fbot2.php%2526scope%253Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Fyoutube%2526response_type%253Dcode%2526access_type%253Doffline" title="Аккаунт Google: TeAOK G9T3arz
(teaokg9t3arz#gmail.com)" role="button" tabindex="0"><span class="gb_8a gbii"></span></a><div class="gb_lb"></div><div class="gb_kb"></div></div><div class="gb_mb gb_ga" aria-label="Информация об аккаунте" aria-hidden="true"><div class="gb_pb"><a class="gb_qb gb_tf gb_sb" aria-label="Изменить картинку профиля" href="https://profiles.google.com/?hl=ru"><div class="gb_tb gbip" title="Профиль"></div><span class="gb_jb">Изменить</span></a><div class="gb_rb"><div class="gb_ub gb_vb">TeAOK G9T3arz</div><div class="gb_wb">teaokg9t3arz#gmail.com</div><div class="gb_ob">Конфиденциальность</div><a class="gb_Fa gb_qf gbp1 gb_xb" href="https://myaccount.google.com/?utm_source=OGB&utm_medium=act">Мой аккаунт</a></div></div><div class="gb_Cb"><div class="gb_Db gb_6a" aria-hidden="true"><a class="gb_Eb gb_Mb" href="/b/0/DelegateAccountSelector?continue=https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2%2Fauth%3Fclient_id%3D702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com%26redirect_uri%3Dhttps%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php%26scope%3Dhttps%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube%26response_type%3Dcode%26access_type%3Doffline&authuser=0"><img class="gb_Ob gb_sb" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="Профиль" data-src="https://lh3.googleusercontent.com/-Yg4816hNGF4/AAAAAAAAAAI/AAAAAAAAAAA/AAyYBF6hOAK-q02pBDqts2Bde8yxxNX1wQ/s48-c-mo/photo.jpg"><div class="gb_Hb"><div class="gb_Pb">TeAOK G9T3arz</div><div class="gb_Qb">teaokg9t3arz#gmail.com (по умолчанию)</div></div></a></div><a class="gb_Sb gb_6a" href="https://myaccount.google.com/brandaccounts?authuser=0&continue=https://accounts.google.com/b/0/DelegateAccountSelector%3Fcontinue%3Dhttps%253A%252F%252Faccounts.google.com%252Fo%252Foauth2%252Fauth%253Fclient_id%253D702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com%2526redirect_uri%253Dhttps%253A%252F%252Fvkmix.com%252Fmodules%252Fyoutube%252Fbot2.php%2526scope%253Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Fyoutube%2526response_type%253Dcode%2526access_type%253Doffline&service=/b/0/DelegateAccountSelector%3Fcontinue%3Dhttps%253A%252F%252Faccounts.google.com%252Fo%252Foauth2%252Fauth%253Fclient_id%253D702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com%2526redirect_uri%253Dhttps%253A%252F%252Fvkmix.com%252Fmodules%252Fyoutube%252Fbot2.php%2526scope%253Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Fyoutube%2526response_type%253Dcode%2526access_type%253Doffline%26authuser%3D%24authuser" aria-hidden="true"><span class="gb_Tb gb_4b"></span><div class="gb_Ub">Все аккаунты брендов »</div></a></div><div class="gb_yb"><div><a class="gb_Fa gb_pf gb_xb" href="https://accounts.google.com/AddSession?continue=https%3A%2F%2Faccounts.google.com%2Fb%2F0%2FDelegateAccountSelector%3Fcontinue%3Dhttps%253A%252F%252Faccounts.google.com%252Fo%252Foauth2%252Fauth%253Fclient_id%253D702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com%2526redirect_uri%253Dhttps%253A%252F%252Fvkmix.com%252Fmodules%252Fyoutube%252Fbot2.php%2526scope%253Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Fyoutube%2526response_type%253Dcode%2526access_type%253Doffline">Добавить аккаунт</a></div><div><a class="gb_Fa gb_rf gb_yf gb_xb" id="gb_71" href="https://accounts.google.com/Logout" target="_top">Выйти</a></div></div></div></div></div></div><div class="gb_Zb gb_R gb_3b" id="gbq1" style="max-width:152px;min-width:152px"><div class="gb_0b"><a class="gb_3d gb_2b" href="/" title="Мой аккаунт" data-ved="0EMQuCAQ"><span class="gb_Za gb_4b"></span></a></div></div></div><div id="gbw"></div></div><div class="gb_sd" id="gba"></div>
<div class="delegate-account-selector main content clearfix">
<div class="sign-in">
<div class="signin-box">
<h2 id="signin-action">Выберите аккаунт</h2>
<ol class="accounts" id="account-list">
<li id="account-teaokg9t3arz#gmail.com">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=none">
<span class="account-image" id="account-image-0"></span>
<span class="account-name">TeAOK G9T3arz</span>
<span class="account-email" id="account-email-0">teaokg9t3arz#gmail.com</span>
<span class="select-account text-icon-select" id="account-account-0">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=105773503169388790046">
<span class="account-image" id="account-image-1"></span>
<span class="account-name">EAccount</span>
<span class="select-account text-icon-select" id="account-account-1">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=116942572818460775716">
<span class="account-image" id="account-image-2"></span>
<span class="account-name">FAccount</span>
<span class="select-account text-icon-select" id="account-account-2">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=110025695516281123129">
<span class="account-image" id="account-image-3"></span>
<span class="account-name">GAccount</span>
<span class="select-account text-icon-select" id="account-account-3">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=100327913140968503320">
<span class="account-image" id="account-image-4"></span>
<span class="account-name">CAccount</span>
<span class="select-account text-icon-select" id="account-account-4">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=114686295257876098243">
<span class="account-image" id="account-image-5"></span>
<span class="account-name">DAccount</span>
<span class="select-account text-icon-select" id="account-account-5">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=101169419531313874972">
<span class="account-image" id="account-image-6"></span>
<span class="account-name">iAccount</span>
<span class="select-account text-icon-select" id="account-account-6">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=116191438938972075200">
<span class="account-image" id="account-image-7"></span>
<span class="account-name">AAccount</span>
<span class="select-account text-icon-select" id="account-account-7">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=106861284959818641724">
<span class="account-image" id="account-image-8"></span>
<span class="account-name">BAccount</span>
<span class="select-account text-icon-select" id="account-account-8">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=104823728391082992328">
<span class="account-image" id="account-image-9"></span>
<span class="account-name">IAccount</span>
<span class="select-account text-icon-select" id="account-account-9">Выберите</span>
</a>
</li>
<li id="account-">
<a href="https://accounts.google.com/o/oauth2/auth?client_id=702580890038-5fs7raaanbrl7rssnkg3e62qgprukbni.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fvkmix.com%2Fmodules%2Fyoutube%2Fbot2.php&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube&response_type=code&access_type=offline&pageId=102918689899435112584">
<span class="account-image" id="account-image-10"></span>
<span class="account-name">JAccount</span>
<span class="select-account text-icon-select" id="account-account-10">Выберите</span>
</a>
</li>
</ol>
</div>
</div>
<div class="side-content">
<div class="product-headers">
<h1 class="redtext">Аккаунты</h1>
</div>
<div class="select-account">
<p>
Выберите аккаунт Google
</p>
<ul>
<li>
TeAOK G9T3arz
(teaokg9t3arz#gmail.com)
</li>
<li>
EAccount
</li>
<li>
FAccount
</li>
<li>
GAccount
</li>
<li>
CAccount
</li>
<li>
DAccount
</li>
<li>
iAccount
</li>
<li>
AAccount
</li>
<li>
BAccount
</li>
<li>
IAccount
</li>
<li>
JAccount
</li>
</ul>
</div>
</div>
</div>
<div class="google-footer-bar">
<div class="footer content clearfix">
<ul id="footer-list">
<li>Google</li>
<li>
<a href="https://accounts.google.com/TOS?loc=RU&hl=ru" >Конфиденциальность и условия</a>
</li>
<li id="footer-help"><a href="https://support.google.com/accounts?hl=ru" >Справка</a></li>
</ul>
</div>
</div>
<script type="text/javascript">
You can try to locate required element by partial link text:
driver.find_element_by_partial_link_text("AAccount").click()
If it doesn't work, you can try to add some time to wait for required element:
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
wait(driver, 10).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "AAccount"))).click()
Related
I'm learning selenium with python, I can't find a way to make it only show me the "premium user" that are shown in the following html code.
<div class="PRINCIPAL">
<!-- PREMIUM USER -->
<li class="MULTILIST_SHOW">
<div class="ROOT">
<span class="PRIMARIO">
<a class="COLOR" href="/maria52" rel="noopener noreferrer" target="_blank">
<img alt="insignia gold" class="USER_LIST_TAB" src="image_insinia.png">
<span class="LINK_USERNAME">
maria52
</span>
</a>
</span>
</div>
</li>
<!-- USER PREMIUM -->
<li class="MULTILIST_SHOW">
<div class="ROOT">
<span class="PRIMARIO">
<a class="COLOR" href="/markpro52" rel="noopener noreferrer" target="_blank">
<img alt="insignia gold" class="USER_LIST_TAB" src="image_insinia.png">
<span class="LINK_USERNAME">
markpro52
</span>
</a>
</span>
</div>
</li>
<!--USER-->
<li class="MULTILIST_SHOW">
<div class="ROOT">
<span class="PRIMARIO">
<a class="COLOR" href="/engan" rel="noopener noreferrer" target="_blank">
<span class="LINK_USERNAME">
engan
</span>
</a>
</span>
</div>
</li>
<!--USER-->
<li class="MULTILIST_SHOW">
<div class="ROOT">
<span class="PRIMARIO">
<a class="COLOR" href="/max300" rel="noopener noreferrer" target="_blank">
<span class="LINK_USERNAME">
max300
</span>
</a>
</span>
</div>
</li>
<!-- USER PREMIUM -->
<li class="MULTILIST_SHOW">
<div class="ROOT">
<span class="PRIMARIO">
<a class="COLOR" href="/leo90" rel="noopener noreferrer" target="_blank">
<img alt="insignia gold" class="USER_LIST_TAB" src="image_insinia.png">
<span class="LINK_USERNAME">
leo90
</span>
</a>
</span>
</div>
</li>
<!--USER-->
<li class="MULTILIST_SHOW">
<div class="ROOT">
<span class="PRIMARIO">
<a class="COLOR" href="/florinda" rel="noopener noreferrer" target="_blank">
<span class="LINK_USERNAME">
florinda
</span>
</a>
</span>
</div>
</li>
</div>
try to do it with this code
def premium_user():
try:
TAG_DIV = driver.find_element(By.TAG_NAME, 'div')
TAG_LI = driver.find_elements(By.TAG_NAME, 'li')
for j in TAG_LI
print(f"USER " + j.text + " IS PREMIUM USER")
premium_user()
but it compiles this
USER maria52 IS PREMIUM USER
USER markpro52 IS PREMIUM USER
USER engan IS PREMIUM USER
USER max300 IS PREMIUM USER
USER leo90 IS PREMIUM USER
USER florinda IS PREMIUM USER
I know that I should tell the program to only print those with the following line but I have not been able to get the program to understand me
<img alt="insignia gold" class="USER_LIST_TAB" src="image_insinia.png">
I am automating with selenium and noticed something weird, on a specific webpage, there is a ul list containing some li roles that are buttons. For some reason, selenium cannot find any of the li's or even the ul unless I inspect element anywhere on the page. I can literally click any other button or interact anywhere, but if I never interact manually with the ul (by manually clicked the li buttons, or inspecting element) selenium cannot find it. please help.
Here is the html code
<ul class="GE0S-T1CMSI mm_tabStrip cw-tab-bar">
<li class="GE0S-T1CCSI GE0S-T1CNSI cw-tab-active">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">Ticket</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Tasks
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Configurations
<span class="GE0S-T1CPRI">1</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Products
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Activities
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Time
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Expenses
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Schedule
<span class="GE0S-T1CPRI">2</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Attachments
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Open Tickets
<span class="GE0S-T1CPRI">34</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Conversions
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">Audit Trail</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
Surveys
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
RMA
<span class="GE0S-T1CPRI">0</span>
</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">Unite</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">Automate Network Map</span>
</li>
<li class="GE0S-T1CCSI">
<a class="GE0S-T1CPSI"></a>
<span class="GE0S-T1CCTI">
<div onload="this.__gwtLastUnhandledEvent="load";" class="cwsvg mm_icon" style="">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 48 48"
focusable="false" viewBox="0 0 48 48">
<g>
<path d="M24 17c-3.9 0-7 3.1-7 7s3.1 7 7 7 7-3.1 7-7-3.1-7-7-7zm0 10c-1.7 0-3-1.3-3-
3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3zm17-.2l-2.7-2.1c0-.2 0-.5 0-.8s0-.5 0-.8L41 21c1-.8
1.3-2.2.7-3.4L38.4 12c-.6-1.1-2-1.6-3.2-1.2l-3.3 1.3c-.5-.3-.9-.6-1.4-.8L30 8c-.2-1-
1.3-2-2.7-2h-6.7c-1.3 0-2.4 1-2.6 2.2l-.5 3.3c-.5.2-.9.5-1.4.8L12.8 11c-1.2-.5-2.6 0-
3.2 1.1l-3.3 5.6c-.6 1.2-.3 2.7.7 3.5l2.7 2.1c0 .3 0 .5 0 .8s0 .5 0 .8L7 26.8c-1 .8-
1.3 2.2-.7 3.4l3.3 5.6c.6 1.1 2 1.6 3.2 1.2l3.3-1.3c.5.3.9.6 1.4.8l.5 3.3c.2 1.3 1.3
2.3 2.6 2.3h6.7c1.3 0 2.4-1 2.6-2.2l.5-3.3c.5-.2.9-.5 1.4-.8l3.3 1.3c1.2.5 2.6 0 3.2-
1.1l3.4-5.6c.6-1.4.3-2.8-.7-3.6zm-6.4-4.2c.1.6.1 1 .1 1.4s0 .8-.1 1.4l-.1 1 3.6 2.8-
2.5 4.1-4.3-1.7-.8.6c-.8.6-1.6 1-2.4 1.4l-1 .4-.7 4.5h-5l-.7-4.5-1-.4c-.8-.3-1.6-.8-
2.4-1.4l-.8-.6-4.3 1.7-2.5-4.1 3.6-2.8-.1-1c-.1-.5-.1-1-.1-1.4s0-.8.1-1.4l.1-1-3.6-2.8
2.5-4.1 4.3 1.7.8-.6c.8-.6 1.6-1 2.4-1.4l1-.4.7-4.5h5l.7 4.5 1 .4c.8.3 1.6.8 2.4
1.4l.8.6 4.3-1.7 2.5 4.1-3.6 2.8.1 1z"></path>
<path d="M0 0h48v48H0z" fill="none"></path>
</g>
</svg>
</div>
</span>
</li>
<li class="GE0S-T1CASI"></li>
<div class="x-clear"></div>
</ul>
Also idk how to copy and paste html code with the indents so yes I spent 30 minutes manually indenting all of that.
but please help
the code I am using is
WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.XPATH,'/html/body/div[2]/div[2]/div/div[1]/div/div[3]/div/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[1]/div[3]/ul/li[6]/span')))
browser.find_element(by=By.XPATH,value='/html/body/div[2]/div[2]/div/div[1]/div/div[3]/div/div[3]/div/div[2]/div/div[2]/div/div[2]/div/div[1]/div[3]/ul/li[6]/span').click()
It works perfectly but only after I inspect the webpage, or if I click the button once manually
the website is connectwise which is my companies ticketing system so I can't provide an exact link.
You should use a better way to find the element on the page instead of using absolute XPATH (more information here)
XPATH expression:
//*[contains(text(),'text here')]
In your case:
//span[contains(text(),'Products')]
Check on your page, to ensure the button can be clicked before or after doing something (Inspect HTML and see what happened when you do that). If yes, perform that action before/after clicking on the button. I recommend that because this html cw-tab-bar and cw-tab-actice
<ul class="GE0S-T1CMSI mm_tabStrip cw-tab-bar">
<li class="GE0S-T1CCSI GE0S-T1CNSI cw-tab-active">
I suggest using another wait condition (read here for more information)
element_to_be_clickable
I have used to below code to extract the href content
soup = bs(html, 'html.parser')
pagesize_content = soup.find_all('div',attrs={'class':"pull-right"})
print(pagesize_content)
When I the class "Pull-right"
output as below
[<div class="col-md-4 pull-right">
<button class="btn btn-default closebutton" data-dismiss="modal" type="button">Close</button>
<button class="btn btn-success" id="Name Properties" type="submit">
Submit
<em class="fa fa-check"></em>
</button>
</div>, <div class="pull-right">
<ul class="pagination">
<li class="disabled">
<a class="disabled" href="javascript:void(0)">
First
<em class="fa fa-angle-double-left"></em>
</a>
</li>
<li class="active">
1
</li>
<li class="">
2
</li>
<li class="">
3
</li>
<li class="">
4
</li>
<li class="">
<a href="/Test/country?page=4">
Last
<em class="fa fa-angle-double-right"></em>
</a>
</li>
</ul>
</div>]
From that how to extract the href link.
When I try with
print(pagesize_content.ul.li.a['href'])
error displaying
pagesize_content = soup.find_all('a',attrs={'class':"fa fa-angle-double-right"},href=True)
print(pagesize_content)
empty output
I'm trying Selenium press Los Angeles word but on the No-professional part.For that I need to press Skate first but in the No-professional part and after press Los Angeles.
To chose between Professional and No-professional I tried driver.find_element_by_xpath("//class[contains(., 'Skate:')][1]").click() (where [1] should set the no profesional part) but is not working.
Second I tried with the completely xpath driver.find_element_by_xpath(".//*[#id='sidebar']/div/ul/li[2]/ul/li[12]/ul/li[4]/span").click(), the problem is the xpath changes everyday so I cannot use it. Here is the HTML Code.
<li class="level-1 profesional ">
<span class="text"><span class="trigger" title="Professional"></span>Professional</span>
<ul style="">
<li class="level-2 collapse">
<span class="text"><span class="sport-icon skate" title="Skate"></span>Skate</span>
<ul style="display:none">
<li class="collapse">
<span class="text"><span class="trigger" title="Los Angeles"></span>Los Angeles</span>
<ul style="display: none;">
<li class="">
<a class="text " href="/es/professional/skate/los-angeles/los-angeles--challenge">
Los Angeles - Challenge
<div class="marker"></div>
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="level-1 no-professional ">
<span class="text"><span title="No professional" class="trigger"></span>No professional</span>
</li>
<li class="level-2 collapse">
<span class="text"><span title="Skate" class="sport-icon skate"></span>Skate</span>
<ul style="display:none">
<li class="collapse">
<span class="text"><span title="Los Angeles" class="trigger"></span>Los Angeles</span>
<ul style="display: none;">
<li class="">
<a href="/es/no-professional/skate/los-angeles/los-angeles--challenge"" class="text ">
Los Angeles - Challenge
<div class="marker"></div>
</a
</li>
Please could you help me.
For the following html:
<ul id="dataset-menu" class="treeview">
<li id="cat_01" class="expandable"></li>
<li id="cat_02" class="collapsable">
<div class="hitarea collapsable-hitarea"></div>
<span class="folder" title=""></span>
<ul style="display: block;">
<li></li>
<li>
<span class="collection">
<div class="cell">
<input id="coll_5555" class="dataset_checkbox" type="checkbox" name="dataset_checkbox" value="5555"></input>
</div>
<div class="cell"></div>
</span>
</li>
<li class="last"></li>
</ul>
</li>
<li id="cat_03" class="expandable"></li>
I have to select the item where the following occurs:
<input id="coll_5555" class="dataset_checkbox" type="checkbox" name="dataset_checkbox" value="5555"></input>
Any idea please?
As i understand first you have to click on li with id cat_02 and then click on the checkbox.
driver.find_element_by_css_selector("#cat_02 div.collapsable-hitarea").click()
driver.find_element_by_id("coll_5555").click();