主要功能未执行我的第二个功能
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了主要功能未执行我的第二个功能相关的知识,希望对你有一定的参考价值。
我已经完成了两个功能,我已经在main中调用了它们。当我执行该程序时,它只会在该程序停止后在主程序中运行第一个功能。如果我将第二个函数粘贴在main中的第一个函数之上,它将仅运行第一个定义的函数,而不运行第二个函数。
package test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class Testing {
public static void login_and_widthdrawl() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/home/ctp-016/Downloads/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://staging.cintech.com/login");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement email = driver.findElement(By.id("email"));
email.sendKeys("zahid12@mailinator.com");
WebElement password = driver.findElement(By.id("password"));
password.sendKeys("zahid12@");
WebElement textbox = driver.findElement(By.id("login"));
textbox.click();
// checking widthdrawl functionality from here
Thread.sleep(4000);
driver.findElement(By.id("navbarDropdown")).click();
driver
.findElement(By.xpath("/html/body/app-root/div/app-header-guest/section[1]/nav/div/div/ul/li[3]/div/a[2]"))
.click();
// SELECTING BTC CRYPTO AND ENTRING VALUES FROM HERE
// WebDriverWait wait = new WebDriverWait(driver, 10);
// WebElement ele = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("/html/body/app-root/div/app-withdrawal/section/div[1]/div/div/div[1]/div/div[1]/span")));
// ele.click();
Thread.sleep(2000);
WebElement submit1 = driver.findElement(By.xpath("//*[@id="select2"]"));
submit1.click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(2000);
WebElement submit12 = driver.findElement(By.xpath("/html/body/span/span/span[2]/ul/li[2]"));
submit12.click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(2000);
WebElement volume =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[1]/input"));
volume.sendKeys("0.001");
WebElement wallet = driver.findElement(By.xpath(
"/html/body/app-root/div/app-withdrawal/section/div[1]/div/div/div[1]/div/div[3]/form/div[2]/div/input"));
wallet.sendKeys("1asas");
WebElement click = driver.findElement(
By.xpath("/html/body/app-root/div/app-withdrawal/section/div[1]/div/div/div[1]/div/div[3]/form/button"));
click.click();
// WebElement secret2 = driver.findElement(By.xpath("//*[@id="VerifyTwoFA"]/div/div/div/app-verify-twofactor/div/div/form/div[1]/input"));
// secret2.sendKeys("0");
WebElement submit2 = driver.findElement(By.id("loginButton"));
submit2.click();
Thread.sleep(2000);
Alert alert = driver.switchTo().alert();
alert.accept();
//driver.quit();
// clear the fields
WebElement volumeclear =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[1]/input"));
volumeclear.clear();
WebElement walletclear =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[2]/input"));
walletclear.clear();
}
public static void ether() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/home/ctp-016/Downloads/chromedriver");
WebDriver driver = new ChromeDriver();
// driver = null;
driver.get("http://staging.cintech.com/login");
// driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// Thread.sleep(2000);
// WebElement selected_value_from_combo = driver.findElement(By.xpath("//*[@id="select2-mySelect2-result-2d1f-3"]"));
// selected_value_from_combo .click();
// driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(2000);
WebElement eth_volume =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[1]/input"));
eth_volume.sendKeys("1");
WebElement eth_wallet =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[2]/input"));
eth_wallet.sendKeys("1asas");
WebElement click_widthdrawl = driver.findElement(
By.xpath("/html/body/app-root/div/app-withdrawal/section/div[1]/div/div/div[1]/div/div[3]/form/button"));
click_widthdrawl.click();
// WebElement secret_eth = driver.findElement(By.xpath("//*[@id="VerifyTwoFA"]/div/div/div/app-verify-twofactor/div/div/form/div[1]/input"));
// secret_eth.sendKeys("0");
WebElement submit_eth = driver.findElement(
By.xpath("//*[@id="VerifyTwoFA"]/div/div/div/app-verify-twofactor/div/div/form/div[2]/button"));
submit_eth.click();
Thread.sleep(2000);
Alert alert_eth = driver.switchTo().alert();
alert_eth.accept();
// clear the fields
WebElement ethvolumeclear =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[1]/input"));
ethvolumeclear.clear();
WebElement ethwalletclear =
driver.findElement(By.xpath("//*[@id="wrapper"]/div[1]/div/div/div[1]/div/div[3]/form/div[2]/input"));
ethwalletclear.clear();
}
public static void main(String[] args) throws InterruptedException {
ether();
login_and_widthdrawl();
}
}
答案
不确定为什么会发生,请尝试此操作以了解实际问题:-
public static void main(String[] args) throws InterruptedException {
try{
ether();
login_and_widthdrawl();
}catch(Exception e){
e.printStackTrace();
}
}
以上是关于主要功能未执行我的第二个功能的主要内容,如果未能解决你的问题,请参考以下文章