Tell me why in one situation the IDE executes the click () method and swears in the other? In this code, it works as it should.
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class SecondTestCase { public static void main(String[] args) throws InterruptedException { // Create a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); //Launch the Website driver.navigate().to("https://www.seleniumhq.org/docs/"); System.out.println("Successfully opened the website www.seleniumhq.org/docs/"); String a = driver.getTitle(); System.out.println("Title is:"+a); //Строка в которой используется метод click() driver.findElement(By.xpath("//div[@class='toctree-wrapper compound']/ul/li[1]/a/em")).click(); String b = driver.getCurrentUrl(); System.out.println("New page is:"+b); driver.navigate().back(); String c=driver.getCurrentUrl(); System.out.println("New new back url:"+c); // Close the driver driver.close(); } }
But if at the end of the line that follows the commentary (// Line in which the click () method is used), actually remove the click () method and transfer it to the next one as driver.click (); then we get the error "Cannot resolve method". Example:
//Строка в которой используется метод click() driver.findElement(By.xpath("//div[@class='toctree-wrapper compound']/ul/li[1]/a/em")); driver.click();
clickmethod is in what thefindElementmethodfindElementand not in thedriverobject? - andy.37