2012-01-29 4 views
1

나는 테스트 용 스프링에서 Firefox webdriver를 시작하려고합니다. startFF 메서드와 같은 프록시를 설정해야합니다. 누군가가 나를 봄 설정으로 도와주세요.스프링 프레임 워크에서 firefoxDriver를 시작하고, 스프링 속성을 설정하십시오.

package stephenn.info; 

import static org.junit.Assert.*; 

import java.io.File; 

import javax.annotation.Resource; 

import org.junit.Test; 
import org.openqa.selenium.Proxy; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxBinary; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.firefox.FirefoxProfile; 
import org.springframework.test.context.ContextConfiguration; 
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; 

@ContextConfiguration(locations = "/applicationContext.xml") 
public class searchTitleTest extends AbstractJUnit4SpringContextTests { 

    @Resource 
    WebDriver webDriver; 

    @Resource 
    Proxy proxy; 

    @Resource 
    FirefoxProfile firefoxProfile; 

    @Test 
    public void testTitle(){ 
     assertTrue(true); 
    } 

    private void startFF(){ 
     Proxy myProxy = new Proxy(); 
     proxy.setHttpProxy("192.168.1.23"); 
     firefoxProfile.setProxyPreferences(myProxy); 
     firefoxProfile.setProxyPreferences(proxy); 
     File ffpath = new File("/usr/bin/firefox"); 
     FirefoxBinary binary = new FirefoxBinary(ffpath); 
     FirefoxDriver ffdriver = new FirefoxDriver(binary,firefoxProfile); 
     ffdriver.close(); 
    } 
} 

.

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 

    <bean id="proxy" class="org.openqa.selenium.Proxy" /> 
    <bean id="firefoxProfile" class="org.openqa.selenium.firefox.FirefoxProfile"> 
     <property name="proxyPreferences"> 
     <ref bean="proxy" /> 
     </property> 
    </bean> 
    <bean class="org.openqa.selenium.firefox.FirefoxDriver" id="webDriver" destroy-method="close" /> 
</beans> 

은 내가 firefoxProfile 콩이 firefoxProfile.setProxyPreferences (프록시)에 대한 속성 proxyPreferences을 번역한다고 생각합니다. 하지만 그것의 잘못된 속성 'proxyPreferences'NotWritablePropertyException 던지고있어.

감사합니다.

답변

0

그래서 내 자신의 질문에 대답하십시오. 레지던트 도사가 이걸 도와 줬어.

봄은 실제 콩 속성에서만 작동합니다. proxyPreferences는 실제 bean 특성이 아니며 setter 메소드 (setProxyPreferences) 만 있습니다. Spring은 getProxyPreferences에 접근하여 변수를 설정했는지 확인하려고 시도하고 있습니다.

감사 6 월

관련 문제