Trying to mimic (automate) email sending through outlook using WinAppDriver, the "New E-mail" element is recognized and new window opens but on the new Window the "To","CC" etc controls are not recognized.
I suspect the new windows session is not available for the driver.
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setPlatform(Platform.WIN10);
//capabilities.setCapability("appTopLevelWindow", "0xBB880A");
capabilities.setCapability("app", "C:\\Program Files\\Microsoft Office\\Office14\\OUTLOOK.exe");
outlookSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
outlookSession.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
} catch (MalformedURLException e) {
e.printStackTrace();
}
newEmail = outlookSession.findElementByName("New E-mail");
System.out.println("newEmail:::::: " + newEmail);
newEmail.click();
outlookSession.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
outlookSession.findElementByName("To").sendKeys("<email>"); (the 'To' element is not recognized.
I think that the problem you are facing is cause by the fact that Outlook will create a new Windows for your new email. That will result in the window not being part of your current session. The best way to address this, is probably creating a desktop session, finding your new window and then attaching a new session and then controlling your new window from there.
Hope this helps.
~Gilles
switchTo().activeElement() didn't work for me so I had to create a new session to interact with the elements on the new email page. Hopefully, this helps others who had the same issue as me
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", "Root");
driver = new WindowsDriver<>(new URL("http://127.0.0.1:4723"), capabilities);
You have to write the code for switching the window from outlook to New email.
Thread.Sleep(TimeSpan.FromSeconds(5));
var allWindowHandles1 = driver.WindowHandles;
driver.SwitchTo().Window(allWindowHandles1[0]);
When ever you have new window then you have to switch the control from one window to other.
Related
I have made a Outlook Addin Angular8 Application using Office.js to interact with Outlook.
Everything works fine, the Addin works fine and stores a CustomPropertie to the Mailitem which can be read after reopening the Mailitem.
In this Implementation this is a simple hashmap.
this.customPropertiesContainer.set('lvAppointmentServiceId', this.selfiId);
this.customPropertiesContainer.saveAsync();
Now I want to read the Propertie in another Application using EWS to get the Mail Item.
Here the Implementation is very complex.
private PropertySet getPropertySetKnown() {
PropertySet propertySet = null;
try {
propertySet = new PropertySet(BasePropertySet.FirstClassProperties, getExtendedPropertyDefinition());
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return propertySet;
}
private ExtendedPropertyDefinition getExtendedPropertyDefinition() throws Exception {
ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.PublicStrings, CATERING_JIRA_ID, MapiPropertyType.String);
return extendedPropertyDefinition;
}
Item boundItem = Item.bind(this.exchangeService, appointmentId, getPropertySetKnown());
jiraCateringId = boundItem.getExtendedProperties().getItems().stream()
.filter(property -> property.getPropertyDefinition().getName().equals(CATERING_JIRA_ID)).findFirst()
.orElse(null);
Does anyone know in which DefaultExtendedPropertySet the Propertie could be found set by Office.js ?
Is there a way to get all Propertis using EWS with no need to define an own Definition?
Is there any Debug Tool in Outlook / Exchange to see the Customproperties in an Item?
As mentioned by #Glen Scales this should answer your question.
Also you can refer the doc Working with extended properties for more details on accessing extended properties from EWS.
I know how to launch a windows application using the filepath to launch it and that works (working example below). I am writing tests and they work too but my question is this: If the application is running already, how do I create my "session" (often called "driver") for the currently running application?
I have read this article that explains how you would connect a new session to Cortana which is already running. It's a great example but my app is an exe that has been launched and is not part of windows and I'm getting the error "Could not find any recognizable digits.".
What am I doing wrong?
WORKING CODE THAT LAUNCHES THE APP AND CREATES THE "session":
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
protected static WindowsDriver<RemoteWebElement> session;
public static void Setup(TestContext context)
{
// Launch app and populate session
if (session == null)
{
// Create a new sessio
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", filepath /*The exeecutable's filepath on c drive*/);
//LaunchWPF app and wpf session
session = new WindowsDriver<RemoteWebElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
}
}
PROBLEM CODE :
[TestMethod()]
public void Common_CreateSession_ForAlreadyRunningmyApp()
{
string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
IntPtr myAppTopLevelWindowHandle = new IntPtr();
foreach (Process clsProcess in Process.GetProcesses())
{
if (clsProcess.ProcessName.Contains("MyApp.Client.Shell"))
{
myAppTopLevelWindowHandle = clsProcess.Handle;
}
}
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("appTopLevelWindow", myAppTopLevelWindowHandle);
//Create session for app that's already running (THIS LINE FAILS, ERROR: : 'Could not find any recognizable digits.')
session = new WindowsDriver<RemoteWebElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
}
}
There's now an answer on github here. You can see on github I have made 3 tweaks to the answer given by moonkey124, 2 of them were obvious (my aplication name and a little sleep command), 1 of them was to adapt the answer to a WPF application under test...
Is it possible to create an OS floating window with Firefox extension? So that the window appears when the browser loses the focus. Googling around didn't bring much. Just need some tutorial / write up on this.
Target OS at the moment - Mac OS X, if it matters.
I apologize if you find this question stupid. At first I'd like to know whether it is possible and feasible to do.
Any thoughts are appreciated.
The pixel perfect extension from the Firebug Working Group does exactly this - please see this file for the full implementation:
https://github.com/firebug/pixel-perfect/blob/master/lib/pixel-perfect-popup.js
The core code to creating the pop-up is in a method called 'createPanel' on line 149:
createPanel: function() {
let browser = getMostRecentBrowserWindow();
let doc = browser.document;
this.panel = doc.createElementNS(XUL_NS, "panel");
this.panel.setAttribute("id", "pixel-perfect-panel");
this.panel.setAttribute("noautohide", "true");
this.panel.setAttribute("titlebar", "normal");
this.panel.setAttribute("noautofocus", "true");
this.panel.setAttribute("label", Locale.$STR("pixelPerfect.title"));
this.panel.setAttribute("close", "true");
this.panel.style.border = "0";
this.panelFrame = doc.createElementNS(XUL_NS, "iframe");
this.panelFrame.setAttribute("type", "content");
this.panelFrame.setAttribute("border", "0");
this.panelFrame.setAttribute("flex", "1");
// xxxHonza: unregister listeners?
DomEvents.on(this.panel, "popuphidden", this.onPopupHidden);
DomEvents.on(this.panel, "popupshown", this.onPopupShown);
this.panelFrame.setAttribute("src", self.data.url("./popup.html"));
this.panel.appendChild(this.panelFrame);
let container = doc.getElementById("mainPopupSet");
container.appendChild(this.panel);
// Load content script and handle messages sent from it.
let { messageManager } = this.panelFrame.frameLoader;
if (messageManager) {
let url = self.data.url("popup-frame-script.js");
messageManager.loadFrameScript(url, false);
messageManager.addMessageListener("message", this.onMessage);
messageManager.addMessageListener("sdk/event/ready", this.onPanelReady);
}
return this.panel;
},
I am getting error of NoSuchWindowException with this code.I am unable to switch back to old opened window and get back to new window
please review my code and help me.
public void TC_123617()throws InterruptedException {
driver.findElement(By.id("user_login")).sendKeys("akhil");
driver.findElement(By.id("user_pass")).sendKeys("akhil");
driver.findElement(By.id("wp-submit")).click();
Thread.sleep(3000);
driver.findElement(By.cssSelector("#awebsome_oruw-2 > ul")).click();
WebElement userStatus = driver.findElement(By.xpath(".//*[#id='awebsome_oruw-2']/ul/li[11]"));
String parentWindow = driver.getWindowHandle();
driver = new FirefoxDriver();
driver .manage().window().maximize();
driver.get("http://103.16.143.96/incis/wp-login.php");
driver.findElement(By.id("user_login")).sendKeys("manager");
driver.findElement(By.id("user_pass")).sendKeys("manager");
driver.findElement(By.id("wp-submit")).click();
for (String popUpHandle : driver.getWindowHandles()) {
if(!popUpHandle.equals(parentWindow)){
driver.switchTo().window(popUpHandle);
driver.switchTo().window(parentWindow);
}
}
}
You don't need to create a new driver instance if you want to switch between windows using driver.
Save a reference to current window. (so that you can return to perform actions on the window you started from.)
String parentWindow = driver.getWindowHandle();
Next Step, get all the windows and switch to the new window.
List<String> allWindows = driver.getWindowHandles();
for(String curWindow : allWindows){
driver.switchTo().window(curWindow);
}
Now, you can perform any action on the new window, and when done you could close it using
driver.close();
Finally, you can switch back to the parent window to continue your actions using
driver.switchTo().window(parentWindow)
I am using Telerik reports in our app and it is being accessed mostly through an RDP session running in "app mode". Everything works fine locally but when I put it on the TS machine it freezes after the print dialog comes up.
The standard print dialog comes up and you can choose the printer and hit ok but then a small box opens with header of Printing... and then never does anything.
I am not sure what code to post since its fine locally, let me know what you want to see. also printing other things like the Telerik grids and charts are fine.
Found the answer on my own.
I created a standard printdialog screen and "rolled my own" print method and all seems to be good. Hope this helps someone else.
private void reportViewer1_Print(object sender, CancelEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
e.Cancel = true;
try
{
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
var result = pd.ShowDialog();
if (result ==DialogResult.OK)
{
// Print the report using the custom print controller
var reportProcessor
= new Telerik.Reporting.Processing.ReportProcessor();
reportProcessor.PrintReport(this.reportViewer1.ReportSource, pd.PrinterSettings);
}
}
catch (Exception ex)
{
Program.ExceptionHandler(ex);
}
this.Cursor = Cursors.Default;
}