Unable to locate elements in Sharepoint modal window with Selenium - selenium

Using Selenium, I'm uploading a file to SharePoint, using upload.aspx in a modal window (So, this is SharePoint out-of-the-box. For whatever reason, I am unable to locate the iframe that SharePoint is using. Can anyone suggest to me a useful technique for this, in SharePoint?

I had the same issue and came up with the following code. This works even if frame name or ID changes dynamically.
driver.switchTo().frame(driver.findElement(By.xpath(".//iframe[#src='yourFrameSourceFromHTML']")));

Related

Selenium select folder windows dialog

]1
There are many examples on what to do with file upload, however I could not find anything in selecting folder. Any ideas how to handle this ?
UPDATE:
I have tried 3 different ways but none worked :
the first is using sendkeys(). This does not work because there is no input field. This dialog opens when you click a button.
The second is using AutoIt, which is used in the uploading files dialog. It causes an error when i use it because I am not uploading a file but just selecting a folder.
the third is robot, where I copy the path I want to the clipboard and try to paste it with robot. It did not work for me.
Update 2:
If you open chrome://extensions/ on chrome browser and tick developer mode you will see a load unpacked extensions buttons. This is the button that when you click you get this windows dialog:
There are different ways by which you can handle File Upload :
Way 1:
WebElement fileInput = driver.findElement(By.name("uploadfile"));
fileInput.sendKeys("C:/path/to/file.jpg");
Way 2:
By using Robot Class API:
driver.findElement(By.By.name("uploadfile")).click();
Robot r = new Robot();
r.keyPress(KeyEvent.VK_KP_DOWN);
r.keyRelease(KeyEvent.VK_KP_DOWN);
r.keyPress(KeyEvent.VK_KP_RIGHT);
r.keyRelease(KeyEvent.VK_KP_RIGHT);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
Hope it will help you
Selenium support is for Web browser and not for windows dialogs.
the only option for you is to write automation using coded UI or Autoit.
Selenium only works on Web browser, You can use AutoIT but I see you already tried it. In that case I would suggest you to use Sikuli.

Drop Down Form for Date is Deformed

I use sharepoint 2010 and I get a deformed pop up menu for Date selection. Nothing fancy here. Just a simple form to enter some data with date.
Have you seen this before? I get the same effect in Chrome/Firefox latest versions.
Thank you in advance
This is a problem with your SharePoint site's CSS (or possibly with JavaScript that affects the CSS).
That big image is a spritesheet; CSS is supposed to crop the visible region so that you only see the specific sprites that are relevant to the current control.
You can pull up the developer tools with F12 and inspect the image element and its containers to see what CSS is currently applied, as well as check for any errors in the JavaScript console.
Clear your browsers cache and reload page. Delete the datetime column and create a new.

Inspect Element Using System.Windows.Forms.WebBrowser

Using the context menu inside internet explorer allows you to inspect the element to see styles etc attached to a html element.
Is there anyway that you enable this functionality inside the webbrowser control?
(I am guessing it is not included to make it lighter, if so is there an alternative?)
It is not my intention to make this available to the client but it would certainly help when debugging the pages sent to the control in my winform application.
As no one seemed to bite on this question I have settled with using the following solution.
https://getfirebug.com/firebuglite#Stable
Using the instructions on this page I was able to press F12 on the webbrowser control to show a "Lite" version of Firebug, this allows me to happily inspect the elements.

Selenium cannot click tab in magento module detail page

I'm trying to validate data using selenium version 1.0.9 in magento grid and its detail page.
First, I walked through Selenium IDE from login page to module detail page and click the tabs available there. Eventually, IDE generates PHP codes so I put the code into proper location.
Note: Here, I have clicked the two tabs so that the events get recorded into selenium IDE.
Then, I run the code from command prompt using following command:
phpunit --configuration /var/www/tests/phpunit_test.xml
I got the error (something like):
ERROR: Element //a[#id='test_tabs_form_section']/span not found.
I modified the code and tried to open the detail page before executing click to above link i.e. "test_tabs_form_section", I am getting same error.
Another strange this is if I verify any text of detail page and remove the code that calls click to module detail tabs, it is works, not sure why?
But I really want to open detail page and click to tab, get forms element values using xpath and validate the data.
Can somebody help me, please?
Any help or suggestion is highly appreciable!
Looking forward to hear from stackoverflow geeks!
Thanks
In case this helps anybody:
I found out more things work if firebug is active. This actually makes sense cause firebug will show the final DOM tree in all it's debugging screens, so it's possible selenium is now able to reconstruct the element path because firebug altered the internal DOM.
If something doesn't work with the default element selection created by Selenium IDE, try switching it over to xpath:id-relative. You're already using that in your question, so maybe you there's an even better selector or you will need to resort to using clickAt instead of click.

Unable to find popup window

I am having an issue with finding a popup window in some selenium test code. I am looking at the screen on the test runner and there are two IE windows, one of them is the popup and one of them the page which generated the popup. However selecting that window with
SelectWindow("name=SomeName")
fails. Putting a break point in there and running some diagnostics shows that
GetAllWindowNames()
returns only one window. Very odd. I have duplicated the problem in IE, chrome and firefox so I don't think it is browser specific. I am using C# to drive my tests. Any idea how I might solve this issue?
Edit:
I looked a bit more at how this page actually creates its popup by reloading itself with window.open added to its code. It is rather an odd way to open a popup but I don't see any reason why it isn't valid.
Is there title or some other attribute in popup window's source code? You can locate that using any info you find there. Try to record open popup window in Se IDE and click on something in that popup window. Usually this trick works.
IIRC, there are some situations where SElenium fails to register the window. In this case you can register the window anyway by using the openWindow(ยดยด, ). I think this is described in the explanation of openWindow in Selenijum IDE...