Code examples for day to day use.

Ask general questions here.
pmaladi
Posts: 10
Joined: Thu Aug 17, 2017 9:42 pm

Code examples for day to day use.

Post by pmaladi » Fri Dec 01, 2017 8:13 pm

Reading attribute value:

Code: Select all

string imgText = urgencyIndicator.GetAttributeValue<string>("Src");  -> to get value using attribute value
Identifying the elements:

Code: Select all

InputTag input = tableSearchCriteria_OCoEFileNet.FindSingle("//td[@innertext='"+fieldName+"']/parent::tr/td[5]/input");   -> from parent to child

pathDirectoryToSaveFileNETPDF.PressKeys("{END}{SHIFT DOWN}{HOME}{SHIFT UP}{DELETE}"); -> to delete content from text box

pathDirectoryToSaveFileNETPDF.TagValue=path;  ->assigning value in text field 
	 Ranorex.THeadTag thtHeader = datePicker.FindDescendant<Ranorex.THeadTag>("calDaysHeader");
            Ranorex.TdTag btnPreviousMonth = thtHeader.FindDescendant<Ranorex.TdTag>("previousMonth");
            Ranorex.TdTag btnNextMonth = thtHeader.FindDescendant<Ranorex.TdTag>("nextMonth");
            Ranorex.TdTag tdMonth = thtHeader.FindDescendant<Ranorex.TdTag>("calMonthCell");
            Ranorex.TdTag btnPreviousYear = thtHeader.FindDescendant<Ranorex.TdTag>("previousYear");
            Ranorex.TdTag btnNextYear = thtHeader.FindDescendant<Ranorex.TdTag>("nextYear");
            Ranorex.TdTag tdYear = thtHeader.FindDescendant<Ranorex.TdTag>("calYearCell");
            Ranorex.TBodyTag tbCalendarBody = datePicker.FindDescendant<Ranorex.TBodyTag>("controlCalBody");
            
            IList<Ranorex.TdTag> ilDisplayedDays = tbCalendarBody.FindDescendants<Ranorex.TdTag>("calcell");
	 IList<Ranorex.TdTag> workBenchCloumn = workBenchRow.FindDescendants<Ranorex.TdTag>();

            while (intDisplayedMonth > intMonth)
            {
                btnPreviousMonth.EnsureVisible();
                btnPreviousMonth.Click();
                intDisplayedMonth = MonthNameToMonthNum(tdMonth.InnerText);
            }

DB connections related code

Code: Select all

	public void openConn(string env)
		{
			
			string HostName,serviceName;
			
			switch(env)
			{
				case "QA":
					HostName="aXX";
					serviceName="TEST_T";
					break;
				case "Dev":
					HostName="amSSSm";
					serviceName="ODFDT";
					break;
				default:
					HostName="";
					serviceName="";
					break;
			}
			
			
			string oradb ="Data Source=(DESCRIPTION = " +
				"(ADDRESS = (PROTOCOL = TCP)(HOST = "+HostName+")(PORT = XXXX))" +
				"(CONNECT_DATA =" +
				"(SERVER = DEDICATED)" +
				"(SERVICE_NAME = "+serviceName+"))" +
				");Persist Security Info=True;User ID=XXXX;Password=XXXX];
			
			try{
				conn = new OracleConnection(oradb);  // C#
				conn.Open();
			}catch (Exception e){
				Report.Fail("DB Connection not opened, Please check once, exception message: "+e.Message);
			}
		}


Ranorex: Shortcuts
https://github.com/icsharpcode/SharpDev ... ortcuts#01
Last edited by pmaladi on Fri Dec 01, 2017 8:21 pm, edited 1 time in total.

pmaladi
Posts: 10
Joined: Thu Aug 17, 2017 9:42 pm

Re: Code examples for day to day use.

Post by pmaladi » Fri Dec 01, 2017 8:21 pm

How to read xml file using ranorex

Code: Select all

public void validateReceipientList(string inputXmlPath)
		{
			XmlDocument document = new XmlDocument();
			document.Load(inputXmlPath);
			XmlNodeList recipientItem = document.GetElementsByTagName("Header_AttributeName");
			foreach (XmlNode childList in recipientItem)
			{
				string attibuteValue_TemplateID = getValue(childList,".//PAth1/PAth2");
				
Perform u r actions according to u r projects

			}
		}


irfan.aloha
Posts: 4
Joined: Mon Dec 04, 2017 10:13 am
Location: Singapore
Contact:

Re: Code examples for day to day use.

Post by irfan.aloha » Fri Dec 22, 2017 11:05 am

Thanks for sharing valuable content.