首先,您可以查看视频并查看我要点击的按钮。这是15秒视频:https://evrenos-hotmail.tinytake.com/sf/MTc4NTkzNV81ODM3MDA5
直接尝试通过Xpath点击该按钮无法点击:
WebElement button = driver.findElement(By.xpath(".//*[@id='DashboardContent']/div[2]/div/div/div[1]/div/div[4]/button"));
button.click();
这是div的html部分:
<div class="col-md-6 col-xs-12 col-sm-6 u-height180 assessment-box assessment-box--orange u-mb15">
<div class="bg-white u-rounded3">
<div class="assessment-box__time c-greydark"><i class="icon_clock_alt"></i> ~ 5 min</div>
<div class="alignment">
<div>
<img src="https://supercv-stg.azureedge.net//Content/images/tests/page-personality.svg?1.0.0.12687" alt="" class="u-maxwidthfull">
<div class="assessment-box__label u-truncate">My Personality</div>
<div class="c-greydark u-font-style-italic u-truncate u-font-small u-lineheight1-2">Gain insight into your unique personality.</div>
</div>
</div>
<div class="assessment-box__percentage" data-percentage="0" style="width: 0%;"></div>
<div class="assessment-box__hover">
<span class="lines"><span></span></span>
<button onclick="continueToTest('/assessments/76/introduction', true)" s-analytics="get-started-assessments-for-personality">Get Started</button>
</div>
</div>
</div>
基本上我想点击&#34;开始使用&#34;这里的按钮<button onclick="continueToTest('/assessments/76/introduction', true)" s-analytics="get-started-assessments-for-personality">Get Started</button>
我还尝试先点击框架激活动画并使按钮可见,然后尝试点击&#34; getstarted&#34;按钮,但也没有用。
WebElement button = driver.findElement(By.xpath(".//*[@id='DashboardContent']/div[2]/div/div/div[1]/div/div[4]/button"));
WebElement frame= driver.findElement(By.xpath(".//*[@id='DashboardContent']/div[2]/div/div/div[1]/div/div[4]"));
frame.click();
Thread.sleep(1500);
button.click();
注意:想要亲自查看页面的人只需在supercareer.com&amp;没有验证,可以进行评估(从左侧面板)检查出来。
答案 0 :(得分:0)
此按钮仅在鼠标悬停在框上后才可用。您可以尝试以下方法,它可能会对您有所帮助。
WebElement button = driver.findElement(By.xpath(".//*[@id='DashboardContent']/div[2]/div/div/div[1]/div/div[4]/button"));
WebElement frame= driver.findElement(By.xpath(".//*[@id='DashboardContent']/div[2]/div/div/div[1]/div"));
new Actions(driver).moveToElement(frame).click(button).perform();