Java 如何在firefox中使用webdriver将密钥发送到电话字段?
我看到firefox打开了,但我没有看到我的号码被插入电话字段! 或者它发生得很快?或者是因为它必须以某种方式标准化 我是否应该以某种方式“放慢”输入速度,让它一个数字一个数字地输入?Java 如何在firefox中使用webdriver将密钥发送到电话字段?,java,testing,xpath,webdriver,testng,Java,Testing,Xpath,Webdriver,Testng,我看到firefox打开了,但我没有看到我的号码被插入电话字段! 或者它发生得很快?或者是因为它必须以某种方式标准化 我是否应该以某种方式“放慢”输入速度,让它一个数字一个数字地输入? 我应该使用显式等待吗?你说你没有看到它,但是你得到的是x的值吗?不要减慢代码的速度,而是尝试在IDE中通过调试模式运行它,或者包含一些日志语句,以帮助您查看代码正在做什么 如果字段中存在预先存在的文本,可以尝试的一件事是首先清除该文本字段: package erjan.testNG.personal_cab
我应该使用显式等待吗?你说你没有看到它,但是你得到的是x的值吗?不要减慢代码的速度,而是尝试在IDE中通过调试模式运行它,或者包含一些日志语句,以帮助您查看代码正在做什么 如果字段中存在预先存在的文本,可以尝试的一件事是首先清除该文本字段:
package erjan.testNG.personal_cabinet;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
public class Login_test {
WebDriver firefox ;
@Test
public void f() {
WebElement login_form
= firefox.findElement(By.id("login-form")) ;
WebElement phone_field = firefox.findElement(By.className("phone-username")) ;
WebElement password_field = firefox.findElement(By.xpath("//input[@type=\"text\"]"));
Assert.assertNotNull(login_form) ;
Assert.assertNotNull(phone_field) ;
Assert.assertNotNull(password_field);
phone_field.sendKeys("4457653245");
String x = phone_field.getText() ;
System.out.println("here we go!!!!!!!!! " + x) ;
}
@BeforeMethod
public void beforeMethod() {
firefox = new FirefoxDriver();
firefox.get("http://test.naimi.me/astana/login");
}
@AfterMethod
public void afterMethod() {
}
}
你说你没有看到它,但是你得到了x的值吗?不要减慢代码的速度,而是尝试在IDE中通过调试模式运行它,或者包含一些日志语句,以帮助您查看代码正在做什么 如果字段中存在预先存在的文本,可以尝试的一件事是首先清除该文本字段:
package erjan.testNG.personal_cabinet;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
public class Login_test {
WebDriver firefox ;
@Test
public void f() {
WebElement login_form
= firefox.findElement(By.id("login-form")) ;
WebElement phone_field = firefox.findElement(By.className("phone-username")) ;
WebElement password_field = firefox.findElement(By.xpath("//input[@type=\"text\"]"));
Assert.assertNotNull(login_form) ;
Assert.assertNotNull(phone_field) ;
Assert.assertNotNull(password_field);
phone_field.sendKeys("4457653245");
String x = phone_field.getText() ;
System.out.println("here we go!!!!!!!!! " + x) ;
}
@BeforeMethod
public void beforeMethod() {
firefox = new FirefoxDriver();
firefox.get("http://test.naimi.me/astana/login");
}
@AfterMethod
public void afterMethod() {
}
}
你说你没有看到它,但是你得到了x的值吗?不要减慢代码的速度,而是尝试在IDE中通过调试模式运行它,或者包含一些日志语句,以帮助您查看代码正在做什么 如果字段中存在预先存在的文本,可以尝试的一件事是首先清除该文本字段:
package erjan.testNG.personal_cabinet;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
public class Login_test {
WebDriver firefox ;
@Test
public void f() {
WebElement login_form
= firefox.findElement(By.id("login-form")) ;
WebElement phone_field = firefox.findElement(By.className("phone-username")) ;
WebElement password_field = firefox.findElement(By.xpath("//input[@type=\"text\"]"));
Assert.assertNotNull(login_form) ;
Assert.assertNotNull(phone_field) ;
Assert.assertNotNull(password_field);
phone_field.sendKeys("4457653245");
String x = phone_field.getText() ;
System.out.println("here we go!!!!!!!!! " + x) ;
}
@BeforeMethod
public void beforeMethod() {
firefox = new FirefoxDriver();
firefox.get("http://test.naimi.me/astana/login");
}
@AfterMethod
public void afterMethod() {
}
}
你说你没有看到它,但是你得到了x的值吗?不要减慢代码的速度,而是尝试在IDE中通过调试模式运行它,或者包含一些日志语句,以帮助您查看代码正在做什么 如果字段中存在预先存在的文本,可以尝试的一件事是首先清除该文本字段:
package erjan.testNG.personal_cabinet;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
public class Login_test {
WebDriver firefox ;
@Test
public void f() {
WebElement login_form
= firefox.findElement(By.id("login-form")) ;
WebElement phone_field = firefox.findElement(By.className("phone-username")) ;
WebElement password_field = firefox.findElement(By.xpath("//input[@type=\"text\"]"));
Assert.assertNotNull(login_form) ;
Assert.assertNotNull(phone_field) ;
Assert.assertNotNull(password_field);
phone_field.sendKeys("4457653245");
String x = phone_field.getText() ;
System.out.println("here we go!!!!!!!!! " + x) ;
}
@BeforeMethod
public void beforeMethod() {
firefox = new FirefoxDriver();
firefox.get("http://test.naimi.me/astana/login");
}
@AfterMethod
public void afterMethod() {
}
}
这不是时间问题 许多表单可能会在接受文本之前请求激活,因此 一种方法是找到元素,单击它,然后插入文本
phone_field.clear();
phone_field.sendKeys("4457653245");
这不是时间问题 许多表单可能会在接受文本之前请求激活,因此 一种方法是找到元素,单击它,然后插入文本
phone_field.clear();
phone_field.sendKeys("4457653245");
这不是时间问题 许多表单可能会在接受文本之前请求激活,因此 一种方法是找到元素,单击它,然后插入文本
phone_field.clear();
phone_field.sendKeys("4457653245");
这不是时间问题 许多表单可能会在接受文本之前请求激活,因此 一种方法是找到元素,单击它,然后插入文本
phone_field.clear();
phone_field.sendKeys("4457653245");
尝试使用以下方法:
phone_field.click();
phone_field.sendKeys("4457653245");
尝试使用以下方法:
phone_field.click();
phone_field.sendKeys("4457653245");
尝试使用以下方法:
phone_field.click();
phone_field.sendKeys("4457653245");
尝试使用以下方法:
phone_field.click();
phone_field.sendKeys("4457653245");