I can't find a way to make it only show me - python

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">

Related

How to view images from folder in flask web app?

I had this issue when I first started on most of the pictures, only one showed on my web page so I uploaded the pictures to a google drive and used each url. It worked but the pictures loaded slowly so I went to try the pictures in a folder thing again and they all show with the alt tag and a broken image icon.
{% extends "base.html" %} {% block title %}Home{% endblock %}
{% block content%}
<main role="main">
<div id="myCarousel" class="carousel slide" data-ride="carousel" style="margin-top:25px;">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="svg-wrapper background-image" style="background-image: url('../images/smiling_five_blue_uniform.jpg'); -webkit-background-composite: border; background-size: cover;">
<!-- <img src="../images/smiling_five_blue_uniform.jpg" class="d-block w-100" alt="KG2 children smiling in school uniform outside TH."> -->
<!-- <img src="https://www.drive.google.com/uc?id=1r-pe153xqSnx08uRzVByAIgXuDmYcLHV" class="d-block w-100" alt="KG2 children smiling in school uniform outside TH."> -->
<svg class="bd-placeholder-img" style="background-image: url('../images/smiling_five_blue_uniform.jpg')" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img"><rect width="100%" height="100%" fill="#777"/>
</svg>
</div>
<div class="container">
<div class="carousel-caption text-left">
<h1>Welcome to Towering Heights Group of Schools</h1>
<p>This is the official website for the Towering Heights group of Schools in Akure, Ondo State.</p>
<p><a class="btn btn-lg btn-primary" href="/about" role="button">See what we're about</a></p>
</div>
</div>
</div>
<div class="carousel-item">
<img src="../images/green_dress_girl.JPG" class="d-block w-100" alt="Children engageing with each other in non-uniform."/>
<!-- <img src="https://www.drive.google.com/uc?id=1tUXIMfDEUmmo5O4yX2ITmJ0-h87XKzW6" class="d-block w-100" alt="Children engageing with each other in non-uniform."> -->
<svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img"><rect width="100%" height="100%" fill="#777"/></svg>
<div class="container">
<div class="carousel-caption">
<h1>Another home for your kids</h1>
<p>We have a warm, safe, secure environment where children have the opportunity
to develop a love of learning and independence.</p>
<p><a class="btn btn-lg btn-primary" href="/contact" role="button">Get in touch today!</a></p>
</div>
</div>
</div>
<div class="carousel-item">
<img src="../images/kids_roundtable.jpg" class="d-block w-100" alt="Children playing at a classroom table inside TH."/>
<!-- <img src="https://www.drive.google.com/uc?id=1NRC2t0FnsJo2gTz_PSmZkA92l-szX2cL" class="d-block w-100" alt="Children playing at a classroom table inside TH."> -->
<svg class="bd-placeholder-img" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img"><rect width="100%" height="100%" fill="#777"/></svg>
<div class="container">
<div class="carousel-caption text-right">
<h1>Admissions are currently ongoing.</h1>
<p>Ensure your child gets the best possible education.</p>
<p><a class="btn btn-lg btn-primary" href="/contact" role="button">Get in touch today</a></p>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</main>
<!-- Marketing messaging and featurettes
================================================== -->
<!-- Wrap the rest of the page in another container to center all the content. -->
<div class="container marketing" style="width:800px; margin:0 auto;">
<!-- Three columns of text below the carousel -->
<div class="container-fluid" style="margin-top:50px;">
<!-- Example row of columns -->
<div class="row" >
<div class="col-lg-4">
<h2>Admissions</h2>
<p>Choosing the right school marks a new beginning in the life of your child.<br>
Contact us as early as possible to have your child assessed and ready for school. </p>
<p><a class="btn btn-secondary" href="/contact" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<h2>Calendar</h2>
<p>Terms, exams, holidays, keep up to date on what's hapenning when so you don't fall behind. </p>
<p><a class="btn btn-secondary" href="/calendar" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
<div class="col-lg-4">
<h2>Latest News</h2>
<p>Check out what's been happening at THS</p>
<p><a class="btn btn-secondary" href="/news" role="button">View details »</a></p>
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->
<hr>
</div> <!-- /container -->
{% endblock %}

How to get the href link from nested HTML tags using python and beautifulsoup?

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

Selenium Web Driver | Find object | Python

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()

Python Selenium differentiate two icon with same name to press one

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.

Select an item from expandable class using selenium python

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();

Categories

Resources