Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.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
Java 自动化具有相同DIV类的组合框_Java_Selenium_Combobox - Fatal编程技术网

Java 自动化具有相同DIV类的组合框

Java 自动化具有相同DIV类的组合框,java,selenium,combobox,Java,Selenium,Combobox,我正在尝试自动化Naukari.com创建工作提醒页面,因为我们有行业字段和工作角色字段。两者都是带有复选框的组合框 //Clicking on the industry dropdown //driver.findElement(By.xpath("//input[contains(@placeholder,'Type or Select')]")).click(); //Selecting the checkbox containing text as "Accounting"

我正在尝试自动化Naukari.com创建工作提醒页面,因为我们有行业字段和工作角色字段。两者都是带有复选框的组合框

 //Clicking on the industry dropdown
 //driver.findElement(By.xpath("//input[contains(@placeholder,'Type or   Select')]")).click();

 //Selecting the checkbox containing text as "Accounting"
 //driver.findElement(By.xpath("//ul[@class='ChkboxEnb']//a[contains(text(),'Accounting')]")).click();

 //Selecting the checkbox containing text as 'Government' 
 //driver.findElement(By.xpath("//ul[@class='ChkboxEnb']//a[contains(text(),'Government')]")).click();
但对于工作角色领域,我再次面临这个问题,因为div类是相同的。我还尝试使用//输入[contains@id,“给定id]”。单击

但它不起作用。请帮忙

尝试下面的代码对FF和Chrome都有效:


选择子属性。根据类名选择DOM,然后使用children属性。这将解决问题。嗨,Shubh,我想同时自动化组合框,即行业和工作类别。一次只使用一个是有效的。@Shubh:no,它正在填充行业,但不是工作类别:它抛出了什么错误,请告诉我@Riki?@Shubh:it抛出了这个错误---未知错误:元素在627423点不可点击。其他元素将收到点击:@Riki:我正在运行它,它工作正常。您使用的是与上面完全相同的代码,还是根据需要修改了某些代码?
    //Sending blank to the industry dropdown so the list is visible
    driver.findElement(By.xpath("//input[@id='cjaInd']")).sendKeys("");

    Actions act = new Actions(driver);

    //Selecting the checkbox containing text exactly as "Accounting , Finance"
    act.moveToElement(driver.findElement(By.xpath("//div[@id='indCja']//ul[@class='ChkboxEnb']//a[.='Accounting , Finance']"))).click().perform();

    //Selecting the checkbox containing text exactly as 'Strategy , Management Consulting Firms' 
    act.moveToElement(driver.findElement(By.xpath("//div[@id='indCja']//ul[@class='ChkboxEnb']//a[.='Strategy , Management Consulting Firms']"))).click().perform();

    //For clicking outside so as the dropdown closes and we can proceed with other action(s)
    act.moveToElement(driver.findElement(By.xpath("//label[.='Industry']"))).click().perform();

    //Sending blank to the Job Category dropdown so the list is visible
    driver.findElement(By.xpath("//input[@id='cjaJob']")).sendKeys("");

    //Selecting the checkbox containing text exactly as Application Programming, Maintenance
    act.moveToElement(driver.findElement(By.xpath("//div[@id='jcCja']//ul[@class='ChkboxEnb']//a[.='Application Programming, Maintenance']"))).click().perform();

    //Selecting the checkbox containing text exactly as "Site Engineering, Project Management"
    act.moveToElement(driver.findElement(By.xpath("//div[@id='jcCja']//ul[@class='ChkboxEnb']//a[.='Site Engineering, Project Management']"))).click().perform();

    //For clicking outside so as the dropdown closes and we can proceed with other action(s)
    act.moveToElement(driver.findElement(By.xpath("//label[.='Industry']"))).click().perform();