这是我第一次编码,请原谅我的无知。
我有以下Selenium代码,用于从餐厅在线订购。最后,它将值放入字段中,检查并打印结果,然后我需要做的就是更改原始输入,然后再次执行。所以我需要一个循环。我认为。
UNION ALL
一切正常,直到这里。我需要做的是返回并将原始输入值(1000)更改为1到1001。我对getInputNumber遇到的错误是“此令牌后应输入AnnotationName”。另外,类“ addnumber”的名称给出错误“非法修饰符,仅允许抽象或最终形式”。 “类”给出错误“语法错误,@预期”。
package Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import java.util.Random;
import java.util.Scanner;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Test {
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\testuser\\Desktop\\Eclipse\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
Actions action = new Actions(driver);
driver.get("onlineorder.com");
//driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS);
WebElement startorder = driver.findElement(By.cssSelector("#startOrder_148"));
startorder.click();
Thread.sleep(4500);
action.sendKeys(Keys.RETURN);
Thread.sleep(3000);
WebElement selectfood = driver.findElement(By.xpath("//a[contains(text(),\"NEW! Steak Po'boy (670 cal)\")]"));
selectfood.click();
Thread.sleep(4000);
WebElement additem = driver.findElement(By.cssSelector("#addItemToOrder"));
additem.click();
Thread.sleep(5000);
WebElement checkout = driver.findElement(By.xpath("//a[contains(text(),'Checkout')]"));
checkout.click();
Thread.sleep(5000);
WebElement loginbutton = driver.findElement(By.cssSelector("#logonCheckoutBtn"));
loginbutton.click();
Thread.sleep(3500);
//WebElement click5 = driver.findElement(By.xpath("//input[@id='email']"));
//action.click(click5).perform();
driver.findElement(By.xpath("//input[@id='email']")).sendKeys("email@gmail.com");
driver.findElement(By.cssSelector("#loginPassword")).sendKeys("password");
WebElement loginbutton2 = driver.findElement(By.cssSelector("#loginButton"));
loginbutton2.click();
Thread.sleep(5500);
WebElement paymenttype = driver.findElement(By.id("selectPaymentType"));
Select payment=new Select(paymenttype);
payment.selectByIndex(3);
driver.findElement(By.id("numberchecker")).sendKeys("1000");
WebElement checkbalance = driver.findElement(By.xpath("//div[@class='clearfix ng-scope']//div[@class='clearfix']//a[@class='numberchecker btn'][contains(text(),'Check balance')]"));
checkbalance.click();
Thread.sleep(1500);
for(WebElement link:driver.findElements(By.xpath("//span[@class='popup_message ng-binding']")))
{
System.out.println(link.getText());
}
WebElement okaybalance = driver.findElement(By.cssSelector("#btnPopupOk"));
okaybalance.click();
}
答案 0 :(得分:-1)
您错误地声明了上课。应该是
public class Sample{
//Then the stuff you want to do.
}
要访问此类,您需要创建外部类对象,并且将其内部 这样。
Outer d=new Outer();
d.Sample obj=new d.Sample();
但是当您为示例类声明成员静态时,您可以使用类名来调用它们。