I have a problem and tried many thing (following-sibling, following etc) but couldn't resolve this.
So I have this structure:
<li>
<span>
<span>
<input type="checkbox">
</span>
</span>
<div>
<span>
<span>Customer</span>
</span>
</div>
</li>
I have like a checkboxes and I wanna locate on checkbox and click on it where text() attribute is Customer.
The XPath to locate checkbox input based on "Customer" text in such XML structure could be:
"//li[.//span[text()='Customer']]//input[#type='checkbox']"
Related
I want to pass in the project.url variable into the th:href attribute of the element, but currently the URL that is navigated to is - /project/project.url/contribute which is obviously not what I wanted to happen.
The list above the button displays the project object's information and the URL is shown correctly.
<ul>
<span>Title: </span>
<li th:text="${project.url}">Title</li>
<span>Started: </span>
<li th:text="${project.publishedOn}">Started</li>
<span>Target: </span>
<li th:text="${project.targets}">Target</li>
<span>Description: </span>
<li th:text="${project.description}">Description</li>
<span>Amount Contributed: </span>
<li th:text="${project.amountContributed}">Amount Contributed</li>
</ul>
<div class="contributeButton">
<button>
<!-- Contribute -->
<a th:href="#{/project/${project.url}/contribute(action='show_all')}">Contribute</a>
</button>
</div>
What href do I need to put inside the link for this to work correctly? Thanks.
You can use concatenation to do this. I haven't tested this but give it a try:
<a th:href="#{'/project/' + ${project.url} + '/contribute(action=\'show_all\')'}">view</a>
You should be taking advantage of Thymeleaf's standard URL syntax for this:
<a th:href="#{/project/{url}/contribute(url=${project.url})}">view</a>
I am new in ajax.
I am trying to get value and want to fill in html code snippet.
I have html code and json object that has value.
Now I want to show the specific value in the different-different part of html code.
Here is my html code:-
<div>
<div class="borb clearfix">
<div class="profileholder fleft">
<img src="images/users/1.png" class="userpic">
<div class="icon state green"></div>
</div>
<div class="remainder">
<div class="padl10">
<div class="username">Anurag Shivpuri</div>
<div class="desig">Cheif Information Officer</div>
<div class="loc">Credit Operation | Pune</div>
</div>
</div>
</div>
<ul class="userdata">
<li>
<span class="lbl">Employee Code :</span>
<span> 2007</span>
</li>
<li>
<span class="lbl">Role_Designation :</span>
<span> Senior HR</span>
</li>
<li>
<span class="lbl">Department :</span>
<span> HR</span>
</li>
<li>
<span class="lbl">Sub_Department :</span>
<span> Talent Acquisition</span>
</li>
<li>
<span class="lbl">Official E-mail Id :</span>
<span> atul.gupta#bajajfinserve.co.in</span>
</li>
<li>
<span class="lbl">Mobile No :</span>
<span> 9844333932</span>
</li>
</ul>
<div class="footbar">
Reward
Incentive
Movement
Leaves
LnD
</div>
On success of ajax I am getting the value now I want to fill it in my html code.
Please help me.
You can use a library (like knockout) to do that, or you can use jQuery to create the elements:
$("<div>").append("some text").appendTo("body"); //creates a div, append some text and...
If you already have a success event in your ajax, you could grab an empty DOM element and set its content.
document.getElementById('placeholder').innerHTML = jsonData.myProperty;
You should use innerHTML in javascript.
Set some ID on the element you need to update:
<li>
<span class="lbl">Employee Code :</span>
<span id='employeeCode'> 2007</span>
</li>
Then update it with your json value:
document.getElementById('employeeCode').innerHTML= yourJsonObject.employeeCodeValue;
I am using Capybara,Rspec and Ruby for my development. I am having drop down list which is populated with values with dynamic ids because of which I am not able locate the element correctly. Here is HTML code. I tried to get the solution from this site as well as by googling. But I couldn't get the correct solution
when I am doing the firebug I am getting Xpath as //[#id='select2-result-label-8'] and every time I am getting new id in the last meaning, next time if I go I will get it as //[#id='select2-result-label-11']. How to resolve this issue. I am having similar issues with my group of check box also. Hope this solution will help there also
<ul id="Values" class="check" role="listbox">
<li class="Reports " role="presentation">
<div id="select2-result-label-3" class="history" role="option">
<span class="same"/>
Add New
</div>
</li>
<li class="Reports-highlighted" role="presentation">
<div id="select2-result-label-4" class="history" role="option">
<span class="same"/>
Multiple
</div>
</li>
<li class="Reports" role="presentation">
<div id="select2-result-label-5" class="history" role="option">
<span class="same"/>
Last
</div>
</li>
</ul>
using prototype, I am trying to hide the specific children element of a particular element.
From the html below, I want to hide child ul and all of its element:
<ul>
<li id="category_1" class="active">
<strong id="img_1" class="cat_plus"></strong>
<input type="checkbox" name="cat_id[]" value="1">
<ul>
<li id="category_3">
<strong id="img_1" class="cat_plus"></strong>
<input type="checkbox" name="cat_id[]" value="3">Root Catalog
</li>
</ul>
<li>
</ul>
i tried:
$('category_1 ul').hide();
I think this is what you are looking for.
$$('#category_1 ul').first().hide();
See fiddle
I hope it helps.
I'm scraping an html document, whose structure changes all the time. Css class names even change, so I can't rely on that. However, one thing never changes, the value is always contained in a subtree exactly like the following:
<span>
<span>
<span>wanted value</span>
<span></span>wanted value
</span>
</span>
Can this be expressed as an XPath expression?
It should not match:
<span>
<span>
<span> 1, one too little </span>
<span> 2 </span>
<span> 3, one too many </span>
<span> 4, two too many </span>
</span>
</span>
I plan to do this using lxml for Python.
If the location of the wanted value is always on the third level of span an xpath as follows will work:
//span/span/span[1]
When applied on the next HTML document:
<html>
<head>
<title>Your Title</title>
</head>
<body>
<div>
<span>
<span>
<span>wanted value</span>
<span></span>
</span>
</span>
</div>
<div>
<span>
<span>
<span>wanted value</span>
<span></span>
</span>
</span>
</div>
</body>
</html>
The result will be:
wanted value
wanted value
EDIT
If you only want the values of the first span on the third level when the total of spans equals 2 on the third level you can use the following XPath:
//span/span[count(span) = 2]/span[1]