인쇄 링크를 클릭 한 후 인쇄 등록 정보 대화 상자 (Windows 구성 요소)가 올바르게 열리는 지 확인하는 시나리오가 있습니다. Java에서 Robot 유틸리티 클래스를 인식하여 Escape/Enter와 같은 키보드 이벤트를 에뮬레이션하여 해당 윈도우에서 작동 할 수 있습니다. 인쇄 즉 대화 제목을 확인하거나 대화가 수 확인 것이다 창 대화 상자 또는 뭔가 다른 텍스트를 검색하는 일이 - Selenium WebDriver : 페이지에 인쇄 윈도우 대화 상자가 표시되는지 확인합니다.
우리가 열어 새로운 대화를 확인할 수있는 방법이 인쇄 대화를 존재인가 대화 상자를 인쇄하십시오.
3
A
답변
1
인쇄 대화 상자가 (아직) 처리 할 수 셀레늄 운영 체제에서 온다. 그러므로 당신은 존재를 확인할 수 없습니다. 내가 생각할 수있는 유일한 방법은 java.awt.Robot을 사용하고, VK_ESCAPE를 보내고, 테스트가 계속된다고 주장한다. 당신이 시도 할 수있는 선발로
이 :
Runnable r = new Runnable() {
@Override
public void run() {
try {
Robot r = new Robot();
r.delay(1000);
r.keyPress(KeyEvent.VK_ESCAPE);
r.keyRelease(KeyEvent.VK_ESCAPE);
} catch (Exception ex) {
ex.printStackTrace();
}
}
};
Actions actions = new Actions(getDriver());
actions.sendKeys(Keys.CONTROL).sendKeys("p");
Thread t = new Thread(r);
t.start();
actions.perform();
//some stupid asserts that we reached here
1
당신이 시각적 인 스튜디오와 함께 제공되는 inspect.exe 도구를 사용할 수 있습니다 (나는 당신이 생각 하겠어) 창에서 작업하는 경우 . 대화 상자와 상호 작용하고 드롭 다운 또는 필요한 다른 상호 작용에서 요소를 선택하는 것을 포함하여 원하는 정보를 정확하게 보낼 수 있습니다. 이것은 셀레늄을 사용하여 파일을 저장하려는 경우에도 작동하지만 질문에 대답하기 위해이 파일을 사용하여 해당 창이 실제로 있는지 여부를 감지 할 수도 있습니다. 거기에서 계속하고 싶은 당신의 전화입니다.
//using System.Windows.Automation;
//using System.Windows.Forms;
AutomationElement desktop = AutomationElement.RootElement;
AutomationElement Firefox = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "MozillaWindowClass"));
AutomationElement PrinterComboBox = PrintForm1.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "1139"));
SelectionPattern selectPrinterComboBox = (SelectionPattern)PrinterComboBox.GetCurrentPattern(SelectionPattern.Pattern);
AutomationElement ItemInDropdown = PrinterComboBox.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "SelectPrintMethod"));
SelectionItemPattern ItemInDropdownSelectItem = (SelectionItemPattern)ItemInDropdown.GetCurrentPattern(SelectionItemPattern.Pattern);
ItemInDropdownSelectItem.Select();
AutomationElement OKButton = PrintForm1.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "1"));
InvokePattern ClickOK = (InvokePattern)OKButton.GetCurrentPattern(InvokePattern.Pattern);
ClickOK.Invoke();
관련 문제
- 1. SaveAs 대화 상자가 표시되는지 확인합니다.
- 2. Selenium webdriver 윈도우 핸들링
- 3. Blackberry - 맞춤법 검사 제안 대화 상자가 표시되는지 확인합니다.
- 4. Java - Selenium WebDriver - 파일 다운로드 대화 상자가 표시되는지 어떻게 확인합니까? (가시성 만 다운로드하지 않음)
- 5. Selenium C# Webdriver 요소가 표시되는지 검색하는 방법
- 6. Webdriver/Selenium Alert 윈도우 문제
- 7. 대화 상자가 여러 번 표시되는지 확인
- 8. Canvas : 브라우저에 표시되는지 확인합니다.
- 9. iOS에서보기가 계속 표시되는지 확인합니다.
- 10. 화면에 대화 상자가 표시되면 Android에서 확인합니다
- 11. Selenium WebDriver : 무작위로 요소가 표시되는지 확인하는 중 오류가 발생했습니다.
- 12. C# 용 Selenium WebDriver - 팝업 대화 상자
- 13. Selenium webdriver IsTextPresent (한 페이지에 두 번 이상)
- 14. Selenium WebDriver : DropDowns 처리
- 15. Selenium WebDriver 및 이미지로드
- 16. selenium webdriver-Java를 사용하여 페이지에 표시된 오류 메시지를 확인하는 방법
- 17. matplotlib 대화 형 모드 : Figure 창이 여전히 표시되는지 확인합니다.
- 18. Selenium WebDriver 페이지 객체
- 19. Selenium Webdriver sendkeys() 작동하지 않습니다.
- 20. Deplhi TEmbeddedWB 요소가 표시되는지 확인합니다.
- 21. 하위보기가 NestedScrollview에서 화면에 표시되는지 확인합니다.
- 22. Selenium WebDriver and Selenium server
- 23. Selenium WebDriver를 사용하여 웹 페이지에 텍스트가 표시되는지 확인
- 24. Selenium 및 C#을 사용하여 페이지에 동적 링크가 표시되는지 확인
- 25. Selenium Webdriver Locators
- 26. Selenium Webdriver 팝업 창 닫기 C#
- 27. 자바 애플릿 인쇄 대화 상자가 사라지지 않습니다
- 28. 최소 시간 동안 jquery 진행 대화 상자가 표시되는지 확인
- 29. Selenium Webdriver - DataGrid의 동적 값 검색
- 30. 대화 상자가 표시되면 안드로이드
Propably 중복 : http://stackoverflow.com/questions/11537103/how-to-handle-print-dialog-in-selenium – Spindizzy
@Spindizzy이 질문은 인쇄 창 대화 상자 처리의 다른 측면을 해결합니다. 여기서 나는 새 창이 인쇄 윈도우를 열었 음을 확인하기 위해 뭔가를 원한다. (윈도우 제목이나 인쇄 대화 상자의 일부 요소를 확인할 수있다.) http://stackoverflow.com/questions/11537103/how-to-handle-print-dialog-in-selenium에서는 대화를 처리하는 방법을 설명하고 내 목적을 달성하지 못합니다! –