How can I access to click on 2nd link inside TextView? So far I tried:
AndroidElement d = (AndroidElement) driver.findElement(By.xpath("//android.widget.TextView[#text='Notice']"));
d.click();
And using:
driver.findElement(By.Id("com.optimum.rdvr.mobile:id/toc_text"));
just clicks on 1st link. And I need to get 2nd link. I want to click on "Mobile Privacy Notice" Any one has suggestion?
You can use Linkify
String termsOfUse = getResources().getString(R.string.terms_of_use);
String privacyNotice = getResources().getString(R.string.privacy_notice);
legalDescription.setText(
String.format(
getResources().getString(R.string.message),
termsOfUse,
privacyNotice )
);
//add the links
Pattern privacyNoticeMatcher = Pattern.compile(privacyNotice);
Linkify.addLinks(legalDescription, privacyNoticeMatcher , "privacy:");
Pattern termsOfUseMatcher = Pattern.compile(termsOfUse);
Linkify.addLinks(legalDescription, termsOfUseMatcher , "termsOfUse:");
via Multiple Clickable links in TextView on Android
I want to add new record in the grid view which is getting displayed on the UI.
I m working on some project in java spring mvc.
There are some already existing records from which some are primary keys and they are not enabled at the time of editing.
So when I click on Add button, controls goes to those which field which are not primary keys means those fields are editable.
So I want to make editable primary keys at the time of adding new record.
public static List<SelectListItem> GetDropDownList<T>(
string text, string value, string selected) where T : class
{
List<SelectListItem> list = new List<SelectListItem>();
list.Add(new SelectListItem { Text = "-Please select-", Value = string.Empty });
IQueryable<T> result = Db.Repository<T>();
var lisData = (from items in result
select items).AsEnumerable().Select(m => new SelectListItem
{
Text = (string)m.GetType().GetProperty(text).GetValue(m),
Value = (string)m.GetType().GetProperty(value).GetValue(m),
Selected = (selected != "") ? ((string)
m.GetType().GetProperty(value).GetValue(m) ==
selected ? true : false) : false,
}).ToList();
list.AddRange(lisData);
return list;
}
}
Currently I'm working on Selenium WebDriver and using Java.
I have a Filter Section with many drop downs
In each drop down I have many options for all the drop downs.
All the options i have put it in a property file called Dropdown.properties
I have a property file (dropdown.properties) in the C: directory. In looks like
visualizationId=Day,Week,Month,Quarter,Semester,Year,RD Tech Group,ICC,Center,Software Pack,Product,Project,Customer PRs,Severity,Priority
periodId=Last 4 Weeks,Last 52 Weeks,Date Range,Week Range,Month Range,Year To Date
classificationId=All PRs,External PRs,Internal PRs,Customer PRs
topographyId=Overall,Center,ICC
swpacksId=ADVIP,ADVLEG,ADVSEC,Boot,H323,IBC,MULTI,None,OneOS_EAD,PROXY,SBO,SIP,TDRE,VoDSL
priorityId=Very Urgent,Urgent,Routine,Not Urgent,On Hold,Not Assigned
severityId=Blocking,Major,Minor,Cosmetic,OLD PR
By using Java for each drop down it need to pick few values from the property file and it need to compare with the UI whether the options is present or not.
It should not check the order or something just want to check whether the randomly picked options from the property file is available in the UI
Please suggest me any solution.
I have read all the values from Property file using the code
Properties APPTEXT = new Properties();
Log.info("Getting Input from the Property file");
FileInputStream fs = new FileInputStream("C:\\FilterSection\\dropdown.properties");
APPTEXT.load(fs);
System.out.println("Propertyfile : " +APPTEXT);
Could any one help me to pick few values from property file and need to check in UI.
This may help you.
public void getRandomOptions(dropdownName)
{
Properties dropdown = new Properties();
InputStream input = null;
String returnString=null;
input = new FileInputStream("yourconfig.properties");
dropdown.load(input);
String records = dropdown.getProperty(dropdownName);
StringTokenizer breaker = new StringTokenizer(records, ",");
int rLocation =(int) Math.random() * (breaker.countTokens()-1);
for(int i=0;i<rLocation ;i++)
{
if(breaker.hasMoreTokens())
returnString = breaker.nextToken();
}
return returnString;
}
This code will retrieve all options
WebElement element = driver.findElement(By.Id("dropdown_id"));
Select select = new Select(element);
List<WebElement> options = select.getOptions();
for(WebElement option : options){
System.out.println(option.getText());
// Compare this value with value retrieved from properties file
}
MenuManager and MenuContribution items has been already created.
For the input Menu Item id/label, I need to problematically drop-down/open/display a menu item from menubar in Eclipse. I think I may need to fire some event.
This is requirement for UI Automation that Menu should be drop down automatically.
Can you please help at the earliest. I'm trying following, but here not sure how to set the x & y co-ordinates where mouse click event should be fired.
Code:
String toCompare = "File";
Menu menu = window.getShell().getMenuBar();
if(menu!=null && !menu.isDisposed()){
MenuItem[] items = menu.getItems();
for(int i=0;i<items.length;i++){
String menuText = LegacyActionTools.removeMnemonics(items[i].getText());
if(toCompare.equalsIgnoreCase(menuText)){
Event event = new Event();
event.doit = true;
event.widget = items[i];
event.type = SWT.MouseDown;
event.button = 1;
boolean success = items[i].getDisplay().post(event);
System.out.println("Could we generate the event ? "+success);
}
}
}
Why don't you use dedicated tools for UI testing, such as SWTBot. It seems typicall matche what you would do
I have a treeview and I wanted to add right click support for the different items. This is how I did it:
http://jsfiddle.net/doonot/xWjSz/
The menu is shown only for the first root module (after right click), but not for the rest of the root modules. Can you tell me what I have to change, in order to get the menu for all root modules?
Thanks a lot, I much appreciate your answer.
Hiya Please see this demo http://jsfiddle.net/hYJPv/1/ or http://jsfiddle.net/hYJPv/ (Fixed the issue) or diff approach here http://jsfiddle.net/UeqBk/for_Dooonot_from_Tats_innit/
on rightclick you will get an alert.
code
$(document).ready(function()
{
// If you want to disable showing the context menu when right clicking
// on the document, the code below would do the trick.
$(document).bind("contextmenu",function(e)
{
alert('right click capture');
return false;
});
var $tree = $("#tree").kendoTreeView(
{
select: function (event)
{
var $item = $(event.node);
console.log( $item );
alert( "selected" );
}
});
// Find the item you want to select...
var $selected = $('#selected');
var $treePath = $selected.parentsUntil($tree, "li");
var treeView = $tree.data('kendoTreeView');
// Expand the tree in order to show the selected item
treeView.expand( $treePath );
// Gotta make both calls...
treeView.select( $selected );
treeView.trigger( 'select', {node: $selected} );
});