Attach image in Internet Explorer

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
KennyLewis
Posts: 5
Joined: Wed Jun 18, 2014 5:27 pm

Attach image in Internet Explorer

Post by KennyLewis » Fri Jun 20, 2014 12:44 am

Hello,

I am trying to attach an image in a web application. I have managed to get the code to work in Chrome because it detects that element. However, it does not work in cross browser testing.

Here is what I have:

Code: Select all

        private void Chrome_PathURL_ComboBox(string folderName)
        {
	        string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
	        DirectoryInfo parentDir = Directory.GetParent(baseDirectory);
	        string updatedDirectory = parentDir.Parent.FullName;
	        updatedDirectory = (updatedDirectory + folderName);
	        	
	        Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'yourtext' with focus on 'Open.PathURL_ComboBox'.", repo.Chrome_Upload.ChromePathURL_ComboBoxInfo);
	        repo.Chrome_Upload.ChromePathURL_ComboBox.PressKeys(updatedDirectory + "{Enter}");
        }
        
        private void FireFox_PathURL_ComboBox(string folderName)
        {
	        string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
	        DirectoryInfo parentDir = Directory.GetParent(baseDirectory);
	        string updatedDirectory = parentDir.Parent.FullName;
	        updatedDirectory = (updatedDirectory + folderName);
	        	
	        Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'yourtext' with focus on 'Open.PathURL_ComboBox'.", repo.FireFox_Upload.FireFoxPathURL_ComboBoxInfo);
	        repo.FireFox_Upload.FireFoxPathURL_ComboBox.PressKeys(updatedDirectory + "{Enter}");
        }
        
        private void IE_PathURL_ComboBox(string folderName)
        {
	        string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
	        DirectoryInfo parentDir = Directory.GetParent(baseDirectory);
	        string updatedDirectory = parentDir.Parent.FullName;
	        updatedDirectory = (updatedDirectory + folderName);
	        	
	        Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'yourtext' with focus on 'Open.PathURL_ComboBox'.", repo.IE_Upload.IEPathURL_ComboBoxInfo);
	        repo.IE_Upload.IEPathURL_ComboBox.PressKeys(updatedDirectory + "{Enter}");
        }
        
        
        public void BrowserImageFile(string folderName, string browser)
        {
        	{
        		if (repo.Chrome_Upload.ChromePathURL_ComboBox.Visible.Equals(true) )
        		{
		        		Chrome_PathURL_ComboBox(folderName);
        		}
        		else if (repo.FireFox_Upload.FireFoxPathURL_ComboBox.Visible.Equals(true) )
        		{
        			FireFox_PathURL_ComboBox(folderName);
        		}
	        	else if (repo.IE_Upload.Self.Visible.Equals(true) )
	        	{
		        		IE_PathURL_ComboBox(folderName);
	        	}

        	}
       	}
    }
The code will run correctly for the first browser, assuming Chrome is the first browser in the test. However, if I run it in FireFox it will time out.

I assume the if statement is incorrect, but was wondering if someone has any pointers. I have attached a screenshot of the current repository

Thanks!
Attachments
Repo.png
Repository
Repo.png (7.83 KiB) Viewed 1062 times
Last edited by Support Team on Fri Jun 20, 2014 9:20 am, edited 1 time in total.
Reason: Misleading title

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Attach image in Windows Explorer

Post by mzperix » Fri Jun 20, 2014 8:09 am

Hi,

This will sound too easy, but did you try to simplify the solution to use only one xpath?

As I can see, the only thing that is different between the xpath's of the browsers is the @title attribute.

Did you try to use only one element?

Just use an Application path like this one: /form[@title='File Upload' or @title='Open' or @title='Choose File to Upload']

Or even just /form ?

Best Regards,
Zoltan