Column value removed on ng-click using tree-grid-directive dynamically - dynamic

The table created on dynamically using ng-repeat with the plugin of Tree-Grid-Directive with the option of Dialog box pop up.
While click on the column value it pop up correctly using ng-click. But after closing dialog box, the td value is missing. I have checked with CSS and coding also. I couldn't find it.
My code is :
<td ng-repeat="col in colDefinitions" ng-controller="treeGridController"
ng-click="(col.field!='col1' && row.branch[col.field]>50)? openTemplate(col.field,row.branch):' ' " ng- style=\"set_color(row.branch[col.field],col.field)\">{{row.branch[col.field]}}</td>
In Inspect Element :
<td ng-repeat="col in colDefinitions" ng-controller="treeGridController" ng-click="(col.field!='col1'&&row.branch[col.field]>50)?openTemplate(col.field,row.branch):''" ng-style="set_color(row.branch[col.field],col.field)" class="ng-scope ng-binding"></td>

We have simply solved with funny work as by changing the function name (openTemplate) to test1 after 3 days

Related

If multiple edit buttons is having same HTML coding how will I click the button in Selenium

I'm new to Selenium. Below is code:
<i _ngcontent-c13="" aria-hidden="true" class="fa fa-edit" style="color: green;cursor: pointer;"></i>
I have all edit buttons with the same type. How do I click on each of the buttons? Can anyone help me with the XPath?
EASY
Right click on element in browser > inspect > right click on the highlighted code > copy > copy xpath. Now we have the xpath so:
driver.findElement(By.xpath("paste_xpath")).some_action();
Let me know if this works, there are more other options to discuss + add the code block that contains all the buttons.
HARD
First we need to get the xpath, you can build it based on the formula:
Xpath=//tagname[#attribute='value']
Where:
// : Select current node.
Tagname: Tagname of the particular node.
#:Select attribute. Attribute: Attribute name of the node.
Value: Value of the attribute.
More details you can find HERE
Thanks,

How to find an item in Selenium WebDriver?

I want to find the following item using Selenium. The value of the class changes whenever there is a change. This is inside a complex page (multiple iframes, and other items loaded dynamically). The only unique id is itemid, which is dynamic value and title combination. If I click on this Action, am getting another new set of complex items. I am new to Selenium. How to do that?
HTML:
<td itemid="xxyyy.as123" title="Actions" nowrap="" class="text-button">Actions <img src="../row.gif"></td>
<td itemid="xxyyy.as123" title="Actions" nowrap="" class="text-button button-active">Actions <img src="../row.gif"></td>
<td itemid="xxyyy.as123" title="Actions" nowrap="" class="text-button button-hover">Actions <img src="../row.gif"></td>
The code I tried:
Find by Xpath
var element=driver.FindElement(By.XPath("html/body/div[id='pageContent']/iframe/#document/ht‌ml/frameset/frame[name='detailsDisplay']/#document/html/body/form[name='tableForm‌']/div[id='divToolbarContainer']/div[id='divToolbar']/div[1][class='toolbar']/tab‌​le/tbody/tr/td[title='Actions']"));
Find by Link Text
var element = driver.FindElement(By.LinkText("Actions"));
Any help would be appreciated.
Try
By.CssSelector("td[title="Actions"]");
By.CssSelector("td[itemid="xxyyy.as123"]");
By.CssSelector("td[itemid="xxyyy.as123"][title="Actions"]")
Create Dynamic CSS Selector.
For Example:
driver.FindElement(By.CssSelector("td[itemid$="xxyyy."]")).Click();
Note: In dynamic Elements, there is always a part of locator wich is fixed. we need to generate the locator using this part.
If fixed part is at starting - Use Carrot Character (^)
If fixed part is at Middle - Use Asterisk sign (*)
If fixed part is at End - Use Doller sign ($)
Finally I was able to achieve it, by using the frame names.
driver.SwitchTo().Frame("content").SwitchTo().Frame("detailsDisplay");
var element = driver.FindElement(By.XPath("//*[#id=\"divToolbar\"]/div[1]/table/tbody/tr/td[1]"));
Thanks everyone.

Python Selenium auto-test (How to get text of a column)

Using Xpath tool from chrome dev tools, I have been able to get xpath string and a td object. I 'm just wondering how do we find the value of text in a td object using selenium python web-drivers?
for your case you can use .gettext() method of selenium.
Once I found that, the attribute within td which contains the text is changing and i was supposed to fetch the text in those attribute.
like
<td class="table__cell" data-col-index="1">
<div class="ec-table__cell-content ">813.75</div>
</td>
<td class="table__cell" data-col-index="2">
<span class="ec-table__cell-content ">522.12</span>
</td>
So to get text within all td in a list, I used dynamic Xpath way:
By.xpath("//td[contains(#class,'table__cell')]/following::*").getText()
Try to search by xpath. Relatively to some ID.
Example of:
id("body_content")/table/tbody/tr/td[3]
in this case will be shown exact elements of 3rd column only.

Checkbox and dropdownbox in selenium

Below is my code
Below is a tag.
<TR id="oldcontent" bgcolor="#D0D0D0">
<TD id="ignore" style="vertical-align:middle">
<input type="checkbox" name="selectedId" value="22047"onclick="updateSelectionList('<%=campaign.getId()%>')">
</TD>
<TD id="oldcontent">Code</TD>
<TD ALIGN="left" id="oldcontent">
<select name="status" style="width=150" id="newcontentformat">
<option value="14" selected="selected">text1</option>
<option value="15">text2</option>
</TD>
<TR>
Here
1)i need to click the checkbox which has dynamically generated value without any string.
2)Can i select the checkbox based on the text "Code" present in next after checkbox?
3)I need to pick up text2 in the dropdown with name status
4)Lastly the issue is this can appear any where in web page,everytime i run the test case.So i need to check the checkbox using String "code",2ndly i need to select value from dropdown which has name staus.There are other dropdown boxes with same name status.So how do i specifically do this?
To get the select list in the row that has the text "Code", you can use the xpath:
//tr[./td[text()='Code']]/td/select
Similarly, for the checkbox, you can use the xpath:
//tr[./td[text()='Code']]/td/input[#type='checkbox']
I believe then the selenium code you want is:
selenium.select("//tr[./td[text()='Code']]/td/select", "text2")
selenium.check("//tr[./td[text()='Code']]/td/input[#type='checkbox']")
As long as there are names available in the HTML, you can use Name to locate an element.
For click on check box you can write:
selenium.click(//input[#name='selectedId']);
To go to check box using text locator should be like:
//div[text()='text you want to precede']/preceding::input[#name='selectedId'];
(here you can use any property instead of name.)
To pickup text from dropdowm:
selenium.select(//select[#name='status'],"text2");
If you use such locators (which are position independent), no matter where your element appears on the screen, you can locate with the help of these locators....
To know more about locating preceding or following Download Ebook:Selenium.1.0.Testing.Tools.Beginners.Guide

How to highlight today's date in DateTextBox in dojo

Is there any way to highlight (show selected) current date in dojo DateTextBox when the text box is empty? I do not want to show the date in the text box (it should remain empty), but just to show today's date as selected.
I tried to use the 'dropDownDefaultValue' attribute provided by dojo for this, but it is not working (current value is not shown as selected or highlighted).
I am using dojo version 1.7.1.
Any suggestions in this regards that will be great.
If you look at the html that is used for the DateTextBox popup you'll see that the td for the current date looks like this:
<td class="dijitCalendarEnabledDate dijitCalendarCurrentDate dijitCalendarCurrentMonth dijitCalendarDateTemplate" role="gridcell" data-dojo-attach-point="dateCells" aria-selected="false" tabindex="0">
<span class="dijitCalendarDateLabel" data-dojo-attach-point="dateLabels">30</span>
</td>
If you want to style the current date so that it appears differently you should update add a css selector like
.dijitCalendarDateTemplate.dijitCalendarCurrentDate{
/*your styling */
background-color: green;
}