猿问

即使在移动到元素并在 Selenium Java 中显式等待后,元素也不可交互

当我点击供应商框时,它会弹出一个选项列表,您可以滚动到或键入您想要的内容并选择。该框有一个明确的 ID,并且在实际页面上肯定是可交互的,但是当我运行测试时,它只是说元素不可交互。


我已经阅读了其他线程并尝试使用 Actions 移动到元素并显式等待,当我完成后,抛出了一个错误“等待元素的可见性”。//尝试移动到元素


    Actions action = new Actions(driver);

    action.moveToElement(driver.findElement(By.id(TransactionUIConstants.VENDOR_SEARCH)));


    WebDriverWait wait = new WebDriverWait(driver, Page.TIMEOUT);

    wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("vendor")))); 

    wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.id("vendor"))));

    //What I'm trying to click


    driver.findElement(By.id("vendor")).click();

    driver.findElement(By.id("vendor")).sendKeys("Amazon");

    driver.findElement(By.id("vendor")).sendKeys(Keys.ENTER);

这是检查选项卡中的描述:


input name="" id="vendor" type="text" autocomplete="nope" placeholder="Select option" tabindex="0" class="multiselect__input" style="width: 0px; position: absolute; padding: 0px ;"


米脂
浏览 160回答 5
5回答

吃鸡游戏

如果它有选择标签,您可以尝试使用选择类。我假设它可能是一个多选下拉列表

慕尼黑的夜晚无繁华

mail.smtp.host=smtp.gmail.commail.smtp.socketFactory.port=465mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactorymail.smtp.auth=truemail.smtp.port=465mail.transport.protocol=smtpresource folder-1

斯蒂芬大帝

utility class- 2 private Folder folder;  public enum EmailFolder {    INBOX("INBOX"),    SPAM("SPAM");    private String text;    private EmailFolder(String text){      this.text = text;    }    public String getText() {      return text;    }  }

慕少森

&nbsp; &nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>javax.mail</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>javax.mail-api</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.5.5</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.sun.mail</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>smtp</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.6.0</version>&nbsp; &nbsp; </dependency>&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.sun.mail</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>javax.mail</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.6.0</version>&nbsp; &nbsp; </dependency>

猛跑小猪

/**&nbsp; &nbsp;* Uses email.username and email.password properties from the properties file. Reads from Inbox folder of the email application&nbsp; &nbsp;* @throws MessagingException&nbsp; &nbsp;*/&nbsp; public EmailUtils() throws MessagingException {&nbsp; &nbsp; this(EmailFolder.INBOX);&nbsp; }&nbsp; /**&nbsp; &nbsp;* Uses username and password in properties file to read from a given folder of the email application&nbsp; &nbsp;* @param emailFolder Folder in email application to interact with&nbsp; &nbsp;* @throws MessagingException&nbsp; &nbsp;*/&nbsp; public EmailUtils(EmailFolder emailFolder) throws MessagingException {&nbsp; &nbsp; this(getEmailUsernameFromProperties(),&nbsp; &nbsp; &nbsp; &nbsp; getEmailPasswordFromProperties(),&nbsp; &nbsp; &nbsp; &nbsp; getEmailServerFromProperties(),&nbsp; &nbsp; &nbsp; &nbsp; emailFolder);&nbsp; }&nbsp; /**&nbsp; &nbsp;* Connects to email server with credentials provided to read from a given folder of the email application&nbsp; &nbsp;* @param username Email username (e.g. janedoe@email.com)&nbsp; &nbsp;* @param password Email password&nbsp; &nbsp;* @param server Email server (e.g. smtp.email.com)&nbsp; &nbsp;* @param emailFolder Folder in email application to interact with&nbsp; &nbsp;*/&nbsp; public EmailUtils(String username, String password, String server, EmailFolder emailFolder) throws MessagingException {&nbsp; &nbsp; Properties props = System.getProperties();&nbsp; &nbsp; try {&nbsp; &nbsp; &nbsp; props.load(new FileInputStream(new File("resources/email.properties")));&nbsp; &nbsp; } catch(Exception e) {&nbsp; &nbsp; &nbsp; e.printStackTrace();&nbsp; &nbsp; &nbsp; System.exit(-1);&nbsp; &nbsp; }&nbsp; &nbsp; Session session = Session.getInstance(props);&nbsp; &nbsp; Store store = session.getStore("imaps");&nbsp; &nbsp; store.connect(server, username, password);&nbsp; &nbsp; folder = store.getFolder(emailFolder.getText());&nbsp; &nbsp; folder.open(Folder.READ_WRITE);&nbsp; }
随时随地看视频慕课网APP

相关分类

Java
我要回答