Selenium获取下拉列表的值代码

 先用Xpath获取drop-down焦点的ID

 

 

//**************************获取下拉列表的值****************

selenium.focus("PoCreateForm_carrierId");                   //获取下拉列表的焦点

selenium.type("PoCreateForm_carrierId", "FedEx");     //填写数据

selenium.keyDown("PoCreateForm_carrierId", "\\40");  //下翻“\\40”是键盘下翻ASCII码

selenium.keyPressNative("10");  //回车以赋的值10键盘回车ASCll码

//*****************************************************

 

 

 

     //************************获取Shipping Carrier的值*************
         selenium.focus("PoCreateForm_carrierId");                 
         selenium.type("PoCreateForm_carrierId", "Pickup");    
         selenium.keyDown("PoCreateForm_carrierId", "\\40"); 
         Thread.sleep(2000);  //线程休息2000
         selenium.keyPressNative(String.valueOf(KeyEvent.VK_ENTER)); //获取键盘回车

   //**********************************************************

你可能感兴趣的:(selenium)