selenium 如何用字符串+ 10位数生成随机数用于:US1525469875 [已关闭]

6ie5vjzr  于 2022-12-04  发布在  其他
关注(0)|答案(1)|浏览(87)

已关闭。此问题需要更多focused。当前不接受答案。
**想要改进此问题吗?**更新问题,使其仅关注editing this post的一个问题。

昨天关门了。
Improve this question
在特征值中,iam发送一个值,i需要生成一个随机值,以US +随机数开始,我们如何才能从特征文件中获取值```然后使用以下内容更新部分标识符部分json“””{ 'ISIN':'US 1525469866','VALOR':'A123500' }“””

@Then("update section Identifiers section  with following json")
  public void updateSectionIdentifiersSectionWithFollowingJson(String json) {
    PageAddInvest PageObjectsFundEligibilityIdentiferAddReInvestleg = new PageAddInvest (Objects.requireNonNull(seleniumCore.getWebDriver()));
    FI objectIdentifiersFromFeatureFile = parserService.jsonToObject(json, FundIdentifier.class);
    boolean b = PageObjectsFundEligibilityIdentiferAddReInvestleg.updateSectionFields(objectIdentifiersFromFeatureFile);
    Assert.assertTrue("Update for the Identifiers  details section failed", b);
  }

 @Override
  public boolean updateSectionFields(DataObject dataObject) {
    boolean flag = false;
    FI  objFundName = (FundIdentifier) dataObject;
    try {
      if (ISIN.isEnabled()) {
        flag = Update(ISIN, objFundName.getISIN());
      }
      if (VALOR.isEnabled()) {
        flag = UpdateFieldValues(VALOR, objFundName.getVALOR());
      }
    } catch (Exception e) {
      log.error(String.valueOf(e));
    }
    return flag;

  }

    public boolean Update(WebElement ele, String valueToField) {
        boolean flag = false;
        try {
            if (element.getAttribute(VALUE).length() <= 0) // Enter value If field value is empty
            {
                ele.sendKeys(valueToField);
                ele.click();
                ele
t.sendKeys(Keys.ENTER);

            } else {
                ele.clear();// If any  field already has value ,clear the value and enter the new value from feature file
                ele.sendKeys(valueToField);
            }

            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }


to generate a new method for generating random number
yzuktlbb

yzuktlbb1#

一种方法是:

RandomUtils.nextLong(111111111111L, 999999999999L);

    for(int i = 0; i < 10; i++){
            System.out.println(RandomUtils.nextLong(111111111111L, 999999999999L));
        }

Apache共享库:

<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>

输出量:

626978522060
473593948333
440832168521
866471810386
535526243677
689974343022
546008098706
479142670371
657040338271
522371045904

相关问题