2017-01-31 4 views
-2

私はseleniumjavaを初めて使用し、プログラムをビルドして複数の問題に直面しています。親クラスのコードは以下の通りです。Selenium-メソッドは型クラスのために未定義です。 Javaクラス拡張中の例外

ログイン方法のエラー。

ボイドは、トークン「(」上の構文エラーの有効なタイプのエラーです。私は変更しようとしたにもかかわらず

、まだ私は

package MyfirstMavenProject.Myfirstgmailtest; 

import java.util.concurrent.TimeUnit; 

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.support.ui.ExpectedConditions; 
import org.openqa.selenium.support.ui.WebDriverWait; 

public class LoginClass { 

    //Open the Browser 
    public void BrowserOpen (String args[]) { 

     WebDriver driver = new FirefoxDriver(); 
     driver.manage().window().maximize(); 

    //Get the URL 
    driver.navigate().to("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier"); 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

    //Identifies the gmail and password 
    public void Login (String args[]) { 

    WebElement emailfield = driver.findElement(By.id("Email")); 
    emailfield.sendKeys("abc.com"); 
     driver.findElement(By.id("next")).click();  
     WebDriverWait wait = new WebDriverWait(driver,30); 
     wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@type='password']"))).sendKeys("abc"); 
     driver.findElement(By.id("signIn")).click();  

    } 
    } 


} 

子クラスがあるエラーに直面しています私は引数に誤りがあります。どの引数を渡す必要がありますか?上記のクラスで作成したログインメソッドを使用しようとしています。

package MyfirstMavenProject.Myfirstgmailtest; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.firefox.FirefoxDriver; 

public class ComposeEmailClass extends LoginClass { 

     //Method to identify the compose email 
    public void ComposeEmail (String args[]){ 

     WebDriver ComposeEmail = new FirefoxDriver();  
     ComposeEmail.findElement(By.className("T-I J-J5-Ji T-I-KE L3")).click(); 
    }` public static void main (String args[]){ 

    ComposeEmailClass ClickCompose = new ComposeEmailClass(); 
    ClickCompose.Login(args);`\\Need more info` 
    ClickCompose.ComposeEmail(args);   
}FireFox.Quit; 
} 

答えて

0

次のコードを使用してください: コードには多くの構文エラーがあります。

ログインクラス:あなたはClickCompose.Login(args);

String[] argsClickCompose.BrowserOpen(args);を呼び出す必要があり

package MyfirstMavenProject.Myfirstgmailtest; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.firefox.FirefoxDriver; 

public class ComposeEmailClass extends LoginClass 
{ 

    //Method to identify the compose email 
    public void ComposeEmail(String args[]) 
    { 
     WebDriver ComposeEmail = new FirefoxDriver();  
     ComposeEmail.findElement(By.className("T-I J-J5-Ji T-I-KE L3")).click(); 
    } 
    public static void main(String args[]) 
    { 
     ComposeEmailClass ClickCompose = new ComposeEmailClass(); 
     ClickCompose.BrowserOpen(args); 
     ClickCompose.Login(args); 
     ClickCompose.ComposeEmail(args);   
    } 

} 

を修正しましたが、あなたのメソッド宣言では必要ありません:はComposeEmailClass

package MyfirstMavenProject.Myfirstgmailtest; 
import java.util.concurrent.TimeUnit; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.support.ui.ExpectedConditions; 
import org.openqa.selenium.support.ui.WebDriverWait; 

public class LoginClass 
{ 
    WebDriver driver =null; 
    //Open the Browser 
    public void BrowserOpen (String args[]) 
    { 
     driver = new FirefoxDriver(); 
     driver.manage().window().maximize(); 
     //Get the URL 
     driver.navigate().to("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier"); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
    } 

    //Identifies the gmail and password 
    public void Login (String args[]) 
    { 

     WebElement emailfield = driver.findElement(By.id("Email")); 
     emailfield.sendKeys("[email protected]"); 
     driver.findElement(By.id("next")).click();  
     WebDriverWait wait = new WebDriverWait(driver,30); 
     wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//* [@type='password']"))).sendKeys("password"); 
     driver.findElement(By.id("signIn")).click();  
    } 
} 

を修正しました。

関連する問題