Open bharadwaj-pendyala opened 6 years ago
You have to be a little bit smart while locating elements using Winium, its kind of complex at times, but can be achieved over the time. Try the following code, which finds the correct xpath in a hierarchical manner starting from the new email window down till the subject line and then enters the subject text. Replace control types, names etc. in the code below if you find them different using spy:
public static void main(String[] args) throws MalformedURLException, InterruptedException {
// TODO Auto-generated method stub
DesktopOptions option = new DesktopOptions();
option.setApplicationPath("C:\\Program Files\\Microsoft Office\\Office15\\OUTLOOK.exe");
WiniumDriver driver = new WiniumDriver(new URL("http://localhost:9999"), option);
Thread.sleep(3000);
driver.findElementByName("Home").click();
driver.findElementByName("New Email").click();
Thread.sleep(3000);
driver.findElement(By.xpath("/*[contains(@ControlType,'ControlType.Window') and contains(@Name,'Untitled - Message')]"
+ "//*[contains(@ControlType, 'ControlType.Pane') and contains(@Name,'Form Regions')]"
+ "//*[contains(@ControlType, 'ControlType.Edit') and contains(@Name,'Subject')]"
)).sendKeys("This is a test");
Thread.sleep(5000);
}
Trying to automate a new scenario where we open the Outlook application and follow below steps.
Enter to email address. Enter subject. Enter email content. Able to automate till Step 1 and Step 3. Only step 2 is not being identified. PFB the below source code. Tried all possible combinations for subject properties. Tried to find it using name - "Subject" and using class name and also automation id. But no luck. Kind of stuck and need help regarding the same.
Thank You.