I have copied the XML code here. And can you please advise the code from below sample? Thanks a lot
WDS.browser.findElement(org.openqa.selenium.By.xpath("//li[contains(#id, 'cascader-menu')]/span[0] ")).click();
if hardcode like this "//li[#id='cascader-menu-9503-0-3']/span", it will work for the current webpage. But it don't work after reloaded.
Sample Code format: id="cascader-menu-8497-0-10"
id="cascader-menu-(Dynamic)-(0->2)-(1->10)"
<div class="el-cascader-panel">
<div class="el-scrollbar el-cascader-menu" role="menu" id="cascader-menu-8497-0">
<div class="el-cascader-menu__wrap el-scrollbar__wrap" style="margin-bottom: -17px; margin-right: -17px;">
<ul class="el-scrollbar__view el-cascader-menu__list">
<li role="menuitem" id="cascader-menu-8497-0-0" tabindex="-1" class="el-cascader-node in-active-path" aria-haspopup="true" aria-owns="cascader-menu-8497-0" aria-expanded="true">
<span class="el-cascader-node__label">九龍</span><i class="el-icon-arrow-right el-cascader-node__postfix">
</i>
</li>
<li role="menuitem" id="cascader-menu-8497-0-1" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0"><span class="el-cascader-node__label">Australia</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><li role="menuitem" id="cascader-menu-8497-0-2" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">British Columbia</span>
<i class="el-icon-arrow-right el-cascader-node__postfix">
</i>
</li>
<li role="menuitem" id="cascader-menu-8497-0-3" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">Greece</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><li role="menuitem" id="cascader-menu-8497-0-4" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">Hong Kong Island</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><li role="menuitem" id="cascader-menu-8497-0-5" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">Kowloon</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><li role="menuitem" id="cascader-menu-8497-0-6" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">New Territories</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li>
<li role="menuitem" id="cascader-menu-8497-0-7" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">Singapore</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li>
<li role="menuitem" id="cascader-menu-8497-0-8" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">Taiwan</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><li role="menuitem" id="cascader-menu-8497-0-9" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">UK</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li>
<li role="menuitem" id="cascader-menu-8497-0-10" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-8497-0">
<span class="el-cascader-node__label">United States</span>
<i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><svg class="el-cascader-menu__hover-zone">
<path style="pointer-events: auto;" fill="transparent" d="M-152 6 L183 0 V6 Z"></path>
<path style="pointer-events: auto;" fill="transparent" d="M-152 40 L183 187 V40 Z"></path>
</svg></ul></div><div class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="transform: translateX(0%);">
</div>
</div>
<div class="el-scrollbar__bar is-vertical">
<div class="el-scrollbar__thumb" style="transform: translateY(0%); height: 48.4456%;">
</div></div></div><div class="el-scrollbar el-cascader-menu" role="menu" id="cascader-menu-4173-1">
<div class="el-cascader-menu__wrap el-scrollbar__wrap" style="margin-bottom: -17px; margin-right: -17px;">
<ul class="el-scrollbar__view el-cascader-menu__list">
<li role="menuitem" id="cascader-menu-4173-1-0" tabindex="-1" class="el-cascader-node" aria-haspopup="true" aria-owns="cascader-menu-4173-1">
<span class="el-cascader-node__label">九龍東</span><i class="el-icon-arrow-right el-cascader-node__postfix"></i>
</li><svg class="el-cascader-menu__hover-zone">
<path style="pointer-events: auto;" fill="transparent" d="M178.40625 6 L207 0 V6 Z"></path>
<path style="pointer-events: auto;" fill="transparent" d="M178.40625 40 L207 187 V40 Z"></path>
</svg>
</ul>
</div>
<div class="el-scrollbar__bar is-horizontal">
<div class="el-scrollbar__thumb" style="transform: translateX(0%);">
</div>
</div>
<div class="el-scrollbar__bar is-vertical">
<div class="el-scrollbar__thumb" style="transform: translateY(0%);">
</div>
</div>
</div>
</div>
It's not XML, it's HTML
It doesn't contain the element you're looking for
Whatever, you can stick to text of the location like:
//span[text()='Shaukeiwan`]
Prior to that you might need to click this Hong Kong Island followed by Mid Level North Point and don't forget to use Explicit Wait to ensure that the element is available/visible/can be clicked
You can see The WebDriver Sampler: Your Top 10 Questions Answered article for example implementation.
Related
I'm trying to get bootstrap tabs to work, but I'm having trouble. When I click on the tab, it doesn't show the right content. Here's my code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
before the
<ul class="nav nav-tabs MentorProfile_Tabs">
<li class="active nav-link"><a data-toggle="tab" href="#experience">Experience</a></li>
<li class="nav-link"><a data-toggle="tab" href="#reviews">Reviews {{numReviews}}</a></li>
</ul>
<div class="tab-content">
<div id="experience" class="tab-pane fade in active" role="tabpanel">
{{#experience}}
<div class="row MentorProfile_ExperienceItem">
<div class="col-md-2"></div>
<div class="col-md-7">
<p class="MentorProfile_ExperienceItemTitle">{{title}}</p>
<p class="MentorProfile_ExperienceItemCompany">{{company}}</p>
</div>
<div class="col-md-3">
<p class="MentorProfile_ExperienceItemDate">{{dateString}}</p>
</div>
</div>
{{/experience}}
</div>
<div id="reviews" class="tab-pane fade" role="tabpanel">
<div class="row MentorProfile_Reviews">
{{#reviews}}
<div class="row MentorProfile_Review">
<div class="row">
<div class="col-sm-8 MentorProfile_Reviews_UserName">{{firstName}} {{lastName}}</div>
<div class="col-md-4">{{{ratingHtml}}}</div>
</div>
<div class="row MentorProfile_Reviews_UserReview">
{{review}}
</div>
</div>
{{/reviews}}
{{^reviews}}
<div class="row MentorProfile_Review">There are no reviews for this mentor at this time.</div>
{{/reviews}}
</div>
</div>
</div>
The way bootstrap 5 tabs works little bit different.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
<div class="d-flex flex-column flex-sm-row justify-content-sm-start align-items-sm-center justify-content-start align-items-center card box-shadow RankItem">
<div class="d-flex flex-column justify-content-center align-items-center LeftSection">
<div class="rank RankNumber"><span>#</span>10</div>
<div class="score">SCORE 7.597</div>
<span class="ChgUp" style="display:none !important;"><i aria-hidden="" class="fas fa-arrow-circle-up" title="up"></i></span>
<span class="ChgDown" style="display:none !important;"><i aria-hidden="" class="fas fa-arrow-circle-down" title="down"></i></span>
<span class="d-flex flex-row align-items-center ChgNeutral" style="display:none !important;">
<i aria-hidden="" class="fa-stack fa-2x" title="no change">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fal fa-arrows-h fa-stack-1x fa-inverse"></i>
</i>
</span>
<span class="d-flex flex-row align-items-center">
<i aria-hidden="" class="fa-stack fa-2x" title="no change">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fal fa-arrows-h fa-stack-1x fa-inverse"></i>
</i>
2019 Rank 10 </span>
</div>
I want to scrape '2019' from this page source using beautiful soup.
I want only the number 2019.Please anyone help
Below is The answer for your question after i checked your previous questions and found by myself what you trying to achieve from this link https://www.vault.com/best-companies-to-work-for/law/top-100-law-firms-rankings/year/2020
from bs4 import BeautifulSoup
html = """
<span class="d-flex flex-row align-items-center">
<i class="fa-stack fa-2x" aria-hidden="" title="no change">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fal fa-arrows-h fa-stack-1x fa-inverse"></i>
</i>
2019 Rank 10 </span>
"""
soup = BeautifulSoup(html, 'html.parser')
for item in soup.findAll('span', attrs={'class': 'd-flex flex-row align-items-center'}):
item = item.text
print(item.strip()[0:4])
Output:
2019
I am working with ASP.net MVC 5, I have created a bootstrap carousel/slideshow with 4 images, I want to get the id of the active slide on this carousel. Then, when an user is clicking on an submit button, I can redirect him to another page recording the active slide id in the URL.
<form method="post">
<div id="mycarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#mycarousel" data-slide-to="0" class=""></li>
<li data-target="#mycarousel" data-slide-to="1"></li>
<li data-target="#mycarousel" data-slide-to="2"></li>
<li data-target="#mycarousel" data-slide-to="3"></li>
</ol>
<a class="carousel-buttonleft" href="#mycarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-buttonright" href="#mycarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<div class="carousel-inner" role="listbox" style="height:300px">
<div class="item active" align="center">
<div align="center" class="carousel-image"><img src="../images/saumon.png" alt="saumon1" /></div>
<div class="carousel-caption">
<p>NORMAL SKIN</p>
</div>
</a>
</div>
<div class="item ">
<div align="center" class="carousel-image">
<img src="../images/saumon.png" alt="saumon1" />
</div>
<div class="carousel-caption">
<p>SILVER SKIN</p>
</div>
</div>
<div class="item " align="center">
<div align="center" class="carousel-image"><img src="../images/saumon.png" alt="saumon1" /></div>
<div class="carousel-caption">
<p>DEEP SKIN</p>
</div>
</div>
<div class="item " align="center">
<div align="center" class="carousel-image"><img src="../images/saumon.png" alt="saumon1" /></div>
<div class="carousel-caption">
<p>WITH SKIN</p>
</div>
</div>
</div>
</div>
Thanks.
sorry i'm currently using my phone. You must select by className.
In css :
.carousel-inner .item .active
In jQuery :
$('.carousel-inner .item .active')
then... .attr('id') and for the value .val() or .text()
In C#, I found this topic to show you how to iterate inside your page controls depending a specific className target :
StackOverflow
how to make the toolbar remains at the bottom, do not go up on top after the keyboard appears ??
what's wrong with my code or less some plugins for cordova or framework7! maybe someone can help me to solve this problem.
<div class="views">
<div class="view">
<div class="pages">
<div data-page="viewprofil" class="page navbar-fixed toolbar-fixed">
<div class="navbar" style="background-color: #1abc9c;box-shadow: 0 5px 10px rgba(0,0,0,0.1), 0 3px 6px rgba(0,0,0,0.1);">
<div class="navbar-inner" >
<div id="kembali" class="left sliding button">
<i class="icon icon-back"></i>
</div>
<div class="left sliding">Akun</div>
</div>
</div>
<div class="toolbar toolbar-bottom">
<div class="toolbar-inner">
<a id="kembali">
<i class="fa fa-home fa-2x" aria-hidden="true"></i>
</a>
<a href="{{pathFor 'history'}}" >
<i class="fa fa-clock-o fa-2x"></i>
</a>
<a href="{{pathFor 'viewprofil'}}" class="toolbar-aktif">
<i class="fa fa-user fa-2x"></i>
</a>
</div>
</div>
<div class="page-content" style="background-color: #ecf0f1;color: #444444;">
<div class="content-block-title" style="top: 0px; margin-top:0px;"><h2>Pengaturan Akun</h2></div>
<div class="list-block">
<ul class="box-data">
<li>
<div class="item-content">
<div class="item-media"><i class="icon material-icons">person</i></div>
<div class="item-inner">
<div class="item-input">
<input id="namalengkap" type="text" placeholder="Nama lengkap" value="{{nama}}">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon material-icons">email</i></div>
<div class="item-inner">
<div class="item-input">
<input type="text" value="{{email}}" disabled>
</div>
</div>
</div>
</li>
<li>
<li class="accordion-item">
<a class="item-content item-link">
<div class="item-media"><i class="icon material-icons" aria-hidden="true">lock</i></div>
<div class="item-inner">
<div class="item-title">Kata Sandi</div>
</div>
</a>
<div class="accordion-item-content">
<div class="content-block" style="margin-left: 80px;">
<input type="password" placeholder="Kata Sandi baru">
</div>
<div class="content-block" style="margin-left: 80px;">
<input type="password" placeholder="Ulangi Kata Sandi">
</div>
</div>
</li>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon material-icons">call</i></div>
<div class="item-inner">
<div class="item-input">
<input type="tel" placeholder="No. Handphone" value="{{notelp}}">
</div>
</div>
</div>
</li>
</ul>
<div class="content-block">
<div class="logButton button button-fill button-raised color-red" id="logout" ><i class="fa fa-power-off " aria-hidden="true"></i> Keluar</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
After
Before
I never came out of an idea to keep it in the bottom, but here is a quick fix:
var myApp = new Framework7({
material: true
});
var mainView = myApp.addView('.view-main', {
});
$$ = Dom7;
$$('#my-input').on('focus', function() {
mainView.hideToolbar();
});
$$('#my-input').on('blur', function() {
mainView.showToolbar();
});
Simply show and hide the toolbar on input focus and blur events.
Live Example: https://jsfiddle.net/wowq3n64/
This works in FF but not I.E. The mouseover on the a tag won't activate. I want to be able to set the class for the a tag when user mouse over it.
<div class="selects-options" id="dropsort"
onmouseover="divshowsort();"
style="position: absolute; top: 8px; left: 1px; width: 153px;display:none;"
onmouseout="hidesort();">
<div class="drop-holder">
<div class="drop-list">
<ul>
<li class="items_selected" id="li1" rel="0">
<a onmouseover="sortclass('li1');"
onclick="divhidesort('R');" href="#">
<span>Relevance</span>
</a>
</li>
<li class="" id="li2" rel="1">
<a onmouseover="sortclass('li2');"
onclick="divhidesort('A');" href="#">
<span>Title A-Z</span>
</a>
</li>
<li class="" id="li3" rel="2">
<a onmouseover="sortclass('li3');"
onclick="divhidesort('D');" href="#">
<span>Newest</span>
</a>
</li>
</ul>
</div>
</div>
</div>