Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
selenium webdriver-检测javascript对话_Java_Selenium Webdriver_Detection_Dialog - Fatal编程技术网

selenium webdriver-检测javascript对话

selenium webdriver-检测javascript对话,java,selenium-webdriver,detection,dialog,Java,Selenium Webdriver,Detection,Dialog,请使用以下凭据验证我的以下URL代码: 网址: 用户名:root 密码:12345678 代码: 您正在尝试按值搜索元素,并使用“按”作为标记名。请改用选项。请检查您的代码,如下所示: d1.switchTo().window("modalbox"); WebElement select = d1.findElement(By.id("getSelectedCountry")); List<WebElement> options = select.findEl

请使用以下凭据验证我的以下URL代码:

网址:

用户名:root

密码:12345678

代码:


您正在尝试按值搜索元素,并使用“按”作为标记名。请改用选项。请检查您的代码,如下所示:

    d1.switchTo().window("modalbox");
    WebElement select = d1.findElement(By.id("getSelectedCountry"));
    List<WebElement> options = select.findElements(By.tagName("option"));

    for (WebElement option : options) {

    if("Qatar".equals(option.getAttribute("value")))

    option.click();   
    }
这会有帮助

WebElement attribute = driver.findElement(By.id("getSelectedCountry");
attribute.sendKeys("Qatar");

在选择国家/地区后添加等待也会有所帮助,因为加载需要时间

嗨,尼廷,非常感谢,伙计……我尝试了这段代码,但它对我不起作用。我想知道是不是少了什么东西。嘿,伙计!!谢谢。这段代码运行得很好,最后我放了attribute.submit;好极了我陷入了另一个步骤,我想单击文本add deal旁边的一个按钮,它没有任何id或名称,只有css或xpath,我编写了如下代码。请建议如何使按钮点击//添加交易列表e2=d1.findElementsBy.xpath/html/body/div/div/div[3]/div[2]/form/div[3]/div/dl/dd/input;System.out.printlncheck1;TryThis WebElement type=driver.findElementBy.xpath//input[@value='Add-Deal'];键入。单击;仅仅依靠Xpath不是一个好主意。因为应用程序将来可能会改变,它在UI上的放置方式也会改变。因此,使用Xpath和一些atribute可以有所帮助。在这种情况下,选择值属性。
WebElement attribute = driver.findElement(By.id("getSelectedCountry");
attribute.sendKeys("Qatar");