2017-01-31 6 views
-2

Я новичок в selenium и java и пытается создать программу и столкнуться с несколькими проблемами. В списке приведен код ниже для родительского класса.Selenium. Метод не определен для класса типа. Исключение во время расширения Java Class

Ошибка метода входа.

Пустота является действительным ошибка типа на синтаксической ошибке на маркер «(».

Даже если я пытался изменить, все равно я столкнуться ошибка

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();  

    } 
    } 


} 

Детский класс, где Я получаю ошибку в аргументе. Мне нужна информация о том, какой аргумент я должен пройти. Я пытаюсь использовать метод Login, созданный в вышеуказанном классе

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

Используйте следующий код: В коде есть много синтаксической ошибки.

Войти Класс: Исправленная

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();  
    } 
} 

ComposeEmailClass: Исправленная

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);   
    } 

} 

Вы должны позвонить ClickCompose.BrowserOpen(args); перед тем ClickCompose.Login(args);

и String[] args не требуется в вашем объявлении метода.