Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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
使用bootstrap/css设计的动态属性。我们无法使用selenium执行操作_Css_Selenium - Fatal编程技术网

使用bootstrap/css设计的动态属性。我们无法使用selenium执行操作

使用bootstrap/css设计的动态属性。我们无法使用selenium执行操作,css,selenium,Css,Selenium,根据上面的代码,我尝试在Selenium中查找元素并对其执行操作 Actions action = new Actions(driver); 控制元素 WebElement we = driver.findElement(By.xpath("//li[@class='static dynamic-children']/a[@href='/activa/gentex/ee/#']/span[@class='additional-background']"));

根据上面的代码,我尝试在Selenium中查找元素并对其执行操作

Actions action = new Actions(driver);
控制元素

          WebElement we = driver.findElement(By.xpath("//li[@class='static dynamic-children']/a[@href='/activa/gentex/ee/#']/span[@class='additional-background']"));
          action.moveToElement(we).build().perform();
          WebDriverWait wait = new WebDriverWait(driver, 50);
      // wait for the edit employee information to appear
      wait.until(ExpectedConditions.presenceOfElementLocated(By
        .xpath("//a[contains(@class,'selected')]/span[@class='additional-background']/span[@class='menu-item-text']")));
//       action.moveToElement(driver.findElement(By.xpath("//div[@id='zz1_TopNavigationMenuV4']/div/ul/li/ul/li/ul/li[2]/a/span/span"))).build().perform();
//        action.click(driver.findElement(By.xpath("//div[@id='zz1_TopNavigationMenuV4']/div/ul/li/ul/li/ul/li[2]/a/span/span"))).perform();
将控件移动到子菜单项以单击它

driver.findElement(By.xpath("//a[contains(@class,'selected')]/span[@class='additional-background']/span[@class='menu-item-text']")).click();

您的xpath似乎不正确,请检查下面的正确代码:

            Actions action = new Actions(driver);

            driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
            WebElement Mainmenu= driver.findElement(By.xpath("//*[@id='zz1_TopNavigationMenuV4']/div/ul/li/ul/li[1]"));
            action.moveToElement(Mainmenu).build().perform();

            WebElement submenu1 = driver.findElement(By.xpath("//*[@id='zz1_TopNavigationMenuV4']/div/ul/li/ul/li[1]/ul/li[1]/a/span/span"));


            WebDriverWait wait = new WebDriverWait(driver, 20);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='zz1_TopNavigationMenuV4']/div/ul/li/ul/li[1]/ul/li[1]/a/span/span")));

            submenu1.click();

我将鼠标悬停在主菜单:我的福利资源上,然后单击子菜单:注册。以上代码对您来说应该可以正常工作。

要阅读标记,请尝试以下操作:

<span>xyz</span>

这应该会有帮助。

你能分享网站URL来检查吗?您还想单击子菜单吗?抱歉,这是内部网访问URL。我可以共享此设计和屏幕截图检查此URL以查看网页您要选择子菜单,对吗?否它不工作它能够验证元素的存在之后它无法单击元素无法定位元素…:(我也尝试过。遇到了相同的问题。它能够识别但不能对元素执行单击操作。
//span[contains(.,'xyz')]