我正在尝试使用Javascript Executor类中有一个元素has**style=“display:none”**但我得到标题中提到的错误。我无法执行sendKeys到文本框
void clickonLaterSignup()
{
WebElement m=driver.findElement(By.xpath("//a[@id='later']"));
WebElement n=driver.findElement(By.xpath("//span[@class='user-signin']"));
WebElement n1=driver.findElement(By.xpath("//button[@class='black-btn-skew btn']"));
m.click();
n.click();
n1.click();
WebDriverWait wait=new WebDriverWait(driver, Duration.ofSeconds(100));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@class='pf-widget-content']")));
driver.findElement(By.xpath("//button[@class='pf-widget-close']")).click();
}
void SignIn()
{
WebElement signInhover= driver.findElement(By.xpath("//span[@class='user-signin']"));
signInhover.click();
WebElement ele= driver.findElement(By.xpath("//div[@class='red-btn-skew btn']"));
ele.click();
//WebElement fname= driver.findElement(By.xpath("//input[@class='gigya-input-text first-capitalize']"));
//fname.sendKeys("Harshit");
((JavascriptExecutor) driver).executeScript("document.getElementById('gigya-textbox-109721930953108590').style.display='block';");
WebElement sname= driver.findElement(By.xpath("//input[@name='profile.lastName']"));
sname.sendKeys("Verma");
WebElement email=driver.findElement(By.xpath("//input[@name='email']"));
email.sendKeys("harshitverma742");
}
public static void main(String args[])
{
System.setProperty("webdriver.chrome.driver","C://Users//vermahg//Downloads//chromedriver_win32 (4)//chromedriver.exe");
driver= new ChromeDriver();
driver.get("https://www.manutd.com/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Main m1=new Main();
m1.clickonLaterSignup();
m1.SignIn();
}
}
1条答案
按热度按时间agxfikkp1#
你不需要修改INPUTs等的可见性来填写表单。下面的代码执行以下步骤:
1.点击登录
1.点击注册按钮
1.填写了大部分表格
我省略了“保持更新”的收音机切换和最后的“联合签名”按钮点击。