主要功能未执行我的第二个功能

栏目: 十大 · 发布时间: 2021-05-07

简介  这篇文章主要介绍了主要功能未执行我的第二个功能以及相关的经验技巧,文章约6254字,浏览量3284,点赞数2,值得参考!

我已经完成了两个功能,我已经在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();
        }
    }

以上就是本文的全部内容,希望对大家的学习有所帮助,本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

Chart.js:在图例点击时刷新第二个Y轴步骤(示例代码)

现学现用-我的第二个小小小私活

将第二个功能添加到单个按钮(示例代码)

我的第二个网页制作:p,hn,br标签的使用

由于休息api延迟,视图寻呼机中的第一个片段未显示

linux下tab作用的描述?

云功能中的云消息传递:admin.messaging(...)。send不是一个功能

OO第二次博客(示例代码)