我正在尝试点击以下网址上的“登录”按钮:
[link] https://exacttarget.com
然后,单击“登录”并单击“在云中进行营销”。
到目前为止,我已经尝试了以下内容并且无效:
driver.findElement(By.xpath("//*[@id='LoginForm']/div[4]/input[1]")).click();
driver.findElement(By.xpath("//input[@class='submit-btn']")).click();
有人可以帮我解决这个问题。
谢谢,Arpan。
<document>
<html class=" js backgroundsize" lang="en" data-placeholder-focus="false">
<head>
<body class="bb-bottom-color">
<!-- preloading images -->
<img style="display:none" alt="" src="/hub-cas/images/hero-image.png"/>
<img style="display:none" alt="" src="/hub-cas/images/hero-image-1.png"/>
<img style="display:none" alt="" src="/hub-cas/images/hero-image-2.png"/>
<div class="wrapper">
<div class="login-header bb-top-color">
<div class="login-form-container bb-top-color clearfix" style="background-image: url("/hub-cas/images/hero-image-1.png");">
<form id="LoginForm" class="login-form" autocomplete="off" method="post" action="/hub- cas/login?wl=NiwzMDAzOTUzLGZlOTg1&service=https%3a%2f%2fimh.s6.exacttarget.com%2fhub%2f">
<input type="hidden" value="e1s1" name="lt"/>
<input id="loginEventId" type="hidden" value="submit" name="_eventId"/>
<div class="login-form-header clearfix">
<div id="jsBrowserDetectionTop" class="notification error" style="display:none"/>
<ul class="login-form-inputs formAttributes">
<div class="login-form-submit-container formAttributes">
<!-- Don't change the style name of the Login input (".submit-btn") without contacting the Security team, as WebMetrics has a dependency on this value. -->
<input class="submit-btn" type="submit" onclick="handleSubmit();" tabindex="4" value="Login"/>
<input id="rememberMeChk" class="checkbox" type="checkbox" tabindex="3"/>
<label for="rememberMeChk">Remember Me</label>
<div class="forgot-pwd">
</div>
<div id="jsBrowserDetectionBottom" style="display:none"/>
<div class="secure-icon"/>
</form>
<div class="login-banner bb-hide">
</div>
<div class="login-footer bb-bottom-color"/>
</div>
<script src="/hub-cas/js/login.js?v=1.0.2" type="text/javascript"/>
</body>
</html>
</document>
答案 0 :(得分:0)
在这种情况下,最好使用CSS选择器IMO -
driver.findElement(By.cssSelector("#LoginForm .submit-btn")).click();
...或者如果你想使用xpath
driver.findElement(By.xpath("//form[@id='LoginForm']//input[@class='submit-btn']")).click();
答案 1 :(得分:0)
这应该有用,
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".submit-btn"))).click();
答案 2 :(得分:0)
我不擅长java所以我会在python中编写代码尝试翻译它。
options=driver.find_elements_by_tag_name("a")
for option in options:
if option.text=="LOGIN":
option.click()
time.sleep(2)
options=driver.find_elements_by_tag_name("a")
for option in options:
if option.text=="Marketing Cloud (formerly IMH)":
option.click()
以上代码对我有用