首页 > 解决方案 > 单击使用 Selenium C# 的 Google 表单测验 ViewScore 按钮

问题描述

我曾尝试单击最后一个按钮以使用 Selenium 查看分数,但它不起作用。我尝试使用 CSSselector。有什么想法会起作用吗?

![1]: https://i.stack.imgur.com/NZ90V.png

try
        {
            var reee = driver.FindElement(By.CssSelector("body > div.freebirdFormviewerViewFormContentWrapper > div:nth-child(2) > div.freebirdFormviewerViewFormCard.exportFormCard > div > div.freebirdFormviewerViewResponseLinksContainer > div > a > span"));
            Actions actions = new Actions(driver);
            actions.MoveToElement(reee);
            Thread.Sleep(2000);
            actions.Click();
            actions.Build().Perform();
        }
        catch
        {
            Console.WriteLine("well not working");
        }

(它适用于提交按钮顺便说一句)(放轻松,我 15 岁)

标签: c#selenium-webdriverselenium-firefoxdriver

解决方案


看看这是否适用于使用链接的文本?

<span class="appsMaterialWizButtonPaperbuttonLabel quantumWizButtonPaperbuttonLabel exportLabel">Преглед на оценката</span>


driver.FindElement(By.Xpath("//span[contains(text(), 'Преглед на оценката')]")).Click();

推荐阅读