简体   繁体   English

Selenium Java 单击按钮后我没有得到预期的结果

[英]Selenium Java after buton click i do not get expected results

This is my method for bypass google verification这是我绕过谷歌验证的方法

public void notABot( ) {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds( 25 ) );
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@name,'a-') and starts-with (@src, 'https://www.google.com/recaptcha')]")));
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div [ @class =  'recaptcha-checkbox-border']"))).click();
driver.switchTo().defaultContent();

and that is working.那是有效的。 In test I also put sleep to slow down selenium little bit.在测试中我也把睡眠放慢了 selenium 一点点。

After that i need to click on the button to confirm registration.之后我需要点击按钮确认注册。 There is info about button.有关于按钮的信息。

<a href="javascript:;" class="button bc-blue register-button-link submit-button sign-up" data-tracking-category="Üyelik" data-tracking-action="Click" data-tracking-label="ÜyeOl" tabindex="27">Otvorite nalog</a>

But i do not get expected result但我没有得到预期的结果

I try to find button @Findby xpath by class and href.我尝试通过 class 和 href 找到按钮@Findby xpath。 Test click on the button and test pass but i do not get what I need.测试单击按钮并测试通过,但我没有得到我需要的东西。

This is what is happening when test pass:这是测试通过时发生的情况: 在此处输入图像描述

and I need to get this我需要得到这个

在此处输入图像描述

I try simple click, java script executor, and I am stacked.我尝试简单的点击,java 脚本执行器,我被堆叠了。 I do not know how to solve this.我不知道如何解决这个问题。 I hope someone could help me我希望有人能帮助我

I tried the below code, it's working fine for me, while clicking on the captcha check box, we have to solve it manually.我尝试了下面的代码,它对我来说工作正常,同时单击验证码复选框,我们必须手动解决它。

driver.findElement(By.id("RegisterFormView_RegisterEmail")).sendKeys("email");
driver.findElement(By.id("RegisterFormView_Password")).sendKeys("password");
driver.findElement(By.id("RegisterPhoneNumberTR")).sendKeys("99536871");

driver.findElement(By.xpath("(.//*[@class='iCheck-helper'])[3]")).click();

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath(".//*[@title='reCAPTCHA']")));

driver.findElement(By.cssSelector(".recaptcha-checkbox-border")).click();

Thread.sleep(15000);  // in this time you have to solve the captcha manually

driver.switchTo().defaultContent();

driver.findElement(By.cssSelector(".button.bc-blue.register-button-link")).click();
public void notABot( ) {

    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds( 15 ));
    wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@name,'a-') and starts-with (@src, 'https://www.google.com/recaptcha')]")));
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div [ @class =  'recaptcha-checkbox-border']"))).click( );
    driver.switchTo().defaultContent();

After this I use在此之后我使用

@FindBy ( xpath = "//a[@class='button bc-blue register-button-link submit-button sign-up']")
WebElement openAccount;

and

public void confirmRegistrationButton( ) {

    openAccount.click();
}

but i still do not get second picture but test fails with explanation但我仍然没有得到第二张照片,但测试失败并有解释

Element: [[ChromeDriver: chrome on WINDOWS (2a833ab11bb1c901d95f62bde96b50a9)] -> xpath: //span/following-sibling::input[@id='RegisterFormView_ActivationCode']]

and this is normal because i did not get that box on picture two这是正常的,因为我没有在图二上看到那个盒子

her is link to Git so maybe someone can help Button Otvorite nalog她是 Git 的链接,所以也许有人可以帮助Button Otvorite nalog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM