使用Selenium自动化测试SAP CRM WebClient UI

<meta charset="utf-8">

package com.xc.crm.test;

import  static  org.junit.Assert.*;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import org.openqa.selenium.By;

import  org.openqa.selenium.NoSuchElementException;

import org.openqa.selenium.WebDriver;

import  org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import  org.openqa.selenium.ie.InternetExplorerDriver;

import  org.openqa.selenium.remote.DesiredCapabilities;

import  org.openqa.selenium.support.ui.ExpectedCondition;

import  org.openqa.selenium.support.ui.WebDriverWait;

public  class CRMTest

{

 private WebDriver myDriver;

 private  String  crmURL;

 private  String  mainWindowHandle;

 private  String  popupWindowHandle;

 @Before

 public  void setUp() throws Exception

       {

//     System.setProperty("webdriver.ie.driver","C:\\xiechuan\\30_Software\\02_Selenium\\IEDriverServer_x64_2.26.2\\IEDriverServer.exe");

//            DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();

//     ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

//            myDriver = new InternetExplorerDriver(ieCapabilities);

 myDriver = new FirefoxDriver();

 crmURL = "https://ldcijerry.corp:44354/sap/bc/bsp/sap/crm_ui_start/default.htm";

       }

 @After

 public  void tearDown() throws Exception

       {

       }

 @Test

 public  void test() throws InterruptedException

       {

              System.out.println("--- Test Start ---");

 // This is for initial the tab in browser

 // myDriver.navigate().to("[http://www.soso.com/](http://www.soso.com/)");

 // Thread.sleep(5000);

 myDriver.navigate().to(crmURL);

              System.out.println("In Testing: Open CRM Logon page");

              Thread.sleep(15000);

 myDriver.findElement(By.id("sap-user")).clear();

 myDriver.findElement(By.id("sap-password")).clear();

 myDriver.findElement(By.id("sap-user")).sendKeys("XIE");

 myDriver.findElement(By.id("sap-password")).sendKeys("Xc12");

 myDriver.findElement(By.cssSelector("span.urBtnCntTxt")).click();

              System.out.println("In Testing: Logon on CRM");

              Thread.sleep(15000);

 myDriver.findElement(By.id("SERVICEPRO")).click();

              System.out.println("In Testing: Click Service Professional");

              Thread.sleep(30000);

 myDriver.switchTo().frame("CRMApplicationFrame");

              Thread.sleep(10000);

 myDriver.switchTo().frame("WorkAreaFrame1");

              Thread.sleep(10000);

              System.out.println("In Testing: Switched to CRMApplicationFrame-WorkAreaFrame1");

 // Create service order

 // AG3

 // myDriver.findElement(By.id("C5_W18_V19_SRV-ORD-DC")).click();

 // QD3

 myDriver.findElement(By.id("C5_W19_V20_SRV-ORD-DC")).click();

              System.out.println("In Testing: Click to create Service Order");

              Thread.sleep(20000);

 // AG3

 // myDriver.findElement(By.id("C31_W109_V112_V113_btrefobjmain_struct.ib_ibase-btn")).click();

 // QD3

 myDriver.findElement(By.id("C32_W114_V117_V118_btrefobjmain_struct.ib_ibase-btn")).click();

              System.out.println("In Testing: Click value help to search IBase");

 mainWindowHandle = myDriver.getWindowHandle();

              System.out.println("In Testing: " + "Main Window: " + mainWindowHandle + " / " + myDriver.getTitle());

              Thread.sleep(10000);

 for (String myHandle : myDriver.getWindowHandles())

              {

                     System.out.println("In Testing: " + "Current Handle: " + myHandle);

 if(!myHandle.equals(mainWindowHandle))

                     {

 popupWindowHandle = myHandle;

 myDriver.switchTo().window(popupWindowHandle);

                           System.out.println("In Testing: " + "Popup Window: " + myDriver.getWindowHandle() + " / " + myDriver.getTitle());

 break;

                     }

              }

 myDriver.switchTo().frame("WorkAreaFrame1");

              System.out.println("In Testing: Switched to pop-up WorkAreaFrame1");

              Thread.sleep(20000);

 // Enter IBase ID

 // AG3

 // myDriver.findElement(By.id("C36_W133_V135_V136_V141_search_parameters[1].VALUE1")).clear();

 // myDriver.findElement(By.id("C36_W133_V135_V136_V141_search_parameters[1].VALUE1")).sendKeys("4448");

 // QD3

 myDriver.findElement(By.id("C37_W137_V139_V140_V145_search_parameters[1].VALUE1")).clear();

 myDriver.findElement(By.id("C37_W137_V139_V140_V145_search_parameters[1].VALUE1")).sendKeys("12");

              System.out.println("In Testing: Pop-up search parameter entered");

 // Click search button

 // AG3

 // myDriver.findElement(By.id("C36_W133_V135_Searchbtn")).click();

 // QD3

 myDriver.findElement(By.id("C37_W137_V139_Searchbtn")).click();

              System.out.println("In Testing: Click search button in Pop-up window");

              Thread.sleep(10000);

 // Select the row in search result

 // AG3

 // myDriver.findElement(By.id("C36_W133_V135_V137_Table_sel_1-rowsel")).click();

 // QD3

 myDriver.findElement(By.id("C37_W137_V139_V141_Table_sel_1-rowsel")).click();

              System.out.println("In Testing: Select search result in Pop-up window");

              Thread.sleep(10000);

              System.out.println("--- Test End ---");

       }

}

原文地址:https://www.cnblogs.com/sap-jerry/p/12321720.html

时间: 2024-08-30 12:29:44

使用Selenium自动化测试SAP CRM WebClient UI的相关文章

Jerry答网友提问:SAP CRM WebClient UI里的EXT,STRUCT等含义

2020年,Jerry会做一个新的尝试,选择部分朋友向我提出的问题,在公众号,知识星球或者微信圈子这些平台上公开回答,这样或许能帮助到更多的朋友. 具体说明参见我前一篇文章:2020年关于SAP知识问答的一个新的尝试 网友的提问: Jerry的解答: 以上截图是CRM系统里BSP_WD_CPMWB这个事务码进入之后,任意打开一个上下文节点(Context Node)看到的信息: STRUCT的含义? 在Jerry之前的文章 Jerry的WebClient UI 42篇原创文章合集 提到这样一张图

SAP CRM WebClient UI和Hybris backoffice UI开发的相同点

CRM WebClient和Hybris backoffice的UI开发都不需要开发人员手写原生的html代码. CRM WebClient UI 在CRM WebUI workbench里,开发人员需要写下图这些SAP封装的tag: 这些Tag能在事物码SE80里找到: Hybris backoffice UI 比如我通过backoffice左边倒L形的工作中心列表查看优惠券列表,这个列表实际上是一棵树,根节点是Marketing. 上图界面是通过在XML文件里定义Hybris封装的tag来实

SAP CRM WebClient UI和Hybris Commerce里的跨组件跳转

CRM WebClient UI How to debug cross component navigation framework https://wiki.scn.sap.com/wiki/display/CRM/How+to+debug+cross+component+navigation+framework Hybris 点了一个产品的图片,系统怎么知道需要load哪个jsp文件来渲染? 之前的issue讨论过,这个点击对应的url,会被Spring MVC map到一个通过@Reque

如何在SAP CRM WebClient UI里创建HANA Live Report

1. 使用业务角色ANALYTICSPRO登录WebClient UI: 2. 点击新建按钮: 为新建的报表分配一个HANA Live Query: 指定Query的参数: 上图WebClient UI选择的参数都定义在HANA studio里: 给报表添加属性: 添加measure: 之后报表即可在WebClient UI里成功渲染: 并且也能在CRM Fiori的Customer Report应用里看到该report. 如果想获得更多关于上图提到的Fiori应用,请查看我的公众号文章 SAP

SAP CRM WebClient UI和Fiori UI混搭并存

SAP CRM里有个功能可以创建HANA live report,消费HANA Studio里创建的模型. 最后创建好的report长这个样子: 具体创建步骤可以参考我的博客Step by Step to create HANA live report in Webclient UI 这些report肉眼上看去显示在WebClient UI里,而WebClient UI似乎不能这么灵活的显示这些风格特异的图标.这是怎么实现的呢? 红色方框里的UI区域实际上是一个UI5应用: Webclient

SAP CRM WebClient UI的on_new_focus应该怎么理解

问题 我在做练习16时(第3步的e,f),发现有一句这样的描述: Double click on method CONNECT_NODES.Make Value node 'Competitors' dependent from BTAdminH. METHOD connect_nodes. DATA: coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper. coll_wrapper = btadminh->get_collection_wr

SAP CRM WebClient UI表格编辑模式的调试明细

如果我们写了EDITMODE = NONE, 那么toolbar不出现是expected的behavior 详见debug: 发现conversation history 里面的table cell可以编辑,这显示不make sense.同事在试图把这些table cell设成readonly的时候发现一些问题,总结如下: (1) 如果BSP html里面加上EDITMODE = "NONE", 则toolbar不会出来.开始同事认为这是framework的问题,但是通过下面的debu

CRM WebClient UI里的文件是如何上传到Netweaver后台的

使用Chrome开发者工具调试CRM WebClient UI里附件上传的功能: 从本地选择一个文件,断点触发: 前端取得用户选中上传的文件名: Jerry.txt 点Attach按钮后,触发ABAP后台的事件处理函数: 从Chrome开发者工具的network标签能观察到,UI向ABAP后台发送了一个http post请求: 后台依次处理所有的form parts: 从对应的form part里取出文件名称和文件类型: 以及实际的文件内容(由于security原因,该form part的内容无

CRM WebClient UI和Hybris里工作中心跳转的url生成逻辑

CRM WebClient UI 把Work center的navigation target在client side不可见:在Chrome development tool里看不到,而是点击了Work center之后,在后台ABAP端计算出navigation target. Hybris 这个Catalog的下拉menu里每个item都对应一个url,在html里用 tag实现.这个url在客户端可见. https://localhost:9002/yacceleratorstorefro