How to create xpath for backtracking to parent node from child node - selenium-webdriver

Currently my requirement is to check the check box at class="ui-checkbox seyc-cell-checkBox-div".
The input which I have is the supplier description present at id="cellDocument2_matrix_block_0_1"
Could you please let me know how to create a Xpath for selecting the check box using the text

"../" will take you one level up. So for example, you are on certain element and you want to navigate 3 levels up in hierarchy you would have to do element.FindElement(By.xpath(../../..));

Found an xpath :
$x("//*[contains(text(),'description')]//ancestor::a/div/div[1]")
Do let me know, incase of any other better approach for location checkbox

Related

How to handle dynamic xpath for newly generated data?

I am working on automating a webpage using PyCharm and Selenium(Python), in which i am creating a data and after creating it, i want to edit/update/delete the data. In my case, the xpath of edit element is rel xpath= //tr[{Digits}]//td[4]//a[1] in which the {Digits} i.e. the row id value keeps on changing, it may increase or decrease according to business requirement. Same goes with delete element rel xpath= //tr[{Digits}]//td[5]//a[1].
What i am trying to achieve is, i want to click the edit and delete elements which is only achievable using the xpaths mentioned above(in which the table row ids are dynamically changing).
Apart from these two elements no other elements are clickable or could make any changes in the record/data which i have created. So is it possible to handle dynamic row ids of the table for the list of the records/data created?
Since i am not allowed to share picture but i could share the following details:
Attributes which i got for Edit element are:
<a class="coral-Link coral-Link--subtle" href="/lucent/service_detail_types/292/edit" style=""><i class="coral-Icon coral-Icon--sizeXS coral-Icon--edit"></i></a>
Attributes which i got for Delete element are:
<a class="coral-Link coral-Link--subtle coral-Form-fielderror" data-confirm="Are you sure you want to delete this?" data-method="delete" href="/lucent/service_detail_types/292" rel="nofollow" xpath="1"><i class="coral-Icon coral-Icon--sizeXS coral-Icon--delete"></i></a>

DecisionTree Selector in AngularJS

I am trying to find a smart way to create a multi-level decision tree selector in angularjs. So, basically what I am looking for is:
If I select Maingroup "GroupA" from a dropdown list, than I should only see the properties from subgroup1 related to GroupA. The subgroup1 should be also a dropdownlist. Then, refining the selection by another dropdownlist, should display only the possible selections based on Maingroup+Subgroup1.
Finally, the value should be displayed.
[{"Maingroup":"GroupA","Subgroup1":"subgroupA1","Subgroup2":"subgroupA21","Value":11.34},
{"Maingroup":"GroupA","Subgroup1":"subgroupA1","Subgroup2":"subgroupA22","Value":40.7},
{"Maingroup":"GroupA","Subgroup1":"subgroupA2","Subgroup2":"subgroupA23","Value":58.23},
{"Maingroup":"GroupA","Subgroup1":"subgroupA2","Subgroup2":"subgroupA24","Value":20.64},
{"Maingroup":"GroupA","Subgroup1":"subgroupA2","Subgroup2":"subgroupA25","Value":74.77},
I have put a screenshot and the json file on github.
Thanks, any suggestion is welcome.
Take a look at angular-ui-tree connected trees demo. The structure can be reused to achieve your goals.

outputting checkbox ids to an empty div

I am currently building a keyword bank to assist in tagging my in-house design assets. My idea is to have each keyword as a checkbox form element with one empty div at the bottom. You'd go through the entire list, check what you need and the text assigned to the id of that checkbox would populate in the empty div, separated by commas, and I can just copy/paste that text right into the metadata. I plan on having hundreds, so I'm hoping there is simple solution to this.
I have no problem setting up the html form/checkboxes, but I am unsure how to make this text populate in that empty div—or even IF it's possible. Would I use jQuery? Ajax? I also don't need a submit button—just that div to update immediately each time a checkbox is touched. Would I also need to have some server-side communication with a submit button to even make this work?
Thank you so much in advance for any help you can give or any direction you can point me in.
Here is a working fiddle
What you need is basically something like this :
$( ":checkbox" ).click(function() {
//alert($( this ).val());
$("#myText").append($(this).val() + ";");
});
You can forget the alert. This will add the value assigned to the checkbox in the div followed with a coma. :)

How to count elements on web page?

Open one web page say gmail.
Want to count that how many text field or buttons or checkbox or hyperlinks or other html elements are present.
The solution is very simple . This can be done using simple XPath.
Find the type of element count you need.
eg for text fields: xpath can be : input[type='text']
for radio buttons: xpath can be : //input[#type='radio']
for check box buttons: xpath can be : //input[#type='checkbox']
so find all the elements in the page by using simple command using the above xpath:
webdriver.findElements(By.xpath("REQUIRED_XPATH")).size();
will give you the number of elements in the particular web page.
I am using c#. If you use c# as well the followings is the something you want to use. And you decide what tags you need inside the selector. I am using all the tags so far.
ReadOnlyCollection<IWebElement> webElements = Driver.FindElements(By.CssSelector("input, select, textarea, a, button"))//and keep adding
//then do a simple count. The trick here is the selector and you need to make sure you are adding all the tag names are being used in your application
webElements.Count();
If you want to count all elements of a page, you can simply use * for that as shown below.
List<WebElement> items = driver.findElements(By.cssSelector("*"));
System.out.println(items);
Here is how to know instantly how many items in the list on the website, for example, languages in the wiki, using right-click "Inspect element".
Screenshot

Expand a tree path by sending the internalId as parameter

Please consider the situation:
I'm using Extjs' tree.Panel to have some sort of navigation on a page.
I have a list of items in another portion of the page, whose list items have a unique id that matches the internalId of a node in the tree.
I wish to bind a click for each list item and expand the tree to the node specified by the id on the item.
I intend to use the expandPath(path) method from the tree. My question would be: how can I get the path string with just the internalId? Thank you.
Unfortunately function NodeInterface.getPath was vanished from extjs4. So there is no way to use expandPath(path). But, instead, you can use
tree.store.getNodeById('ext-record-23').bubble(function(node){node.expand()});

Resources