0
votes

i am using selenium page object model below is the problem scenario i am clicking on an element using below command

driver.findElement(By.xpath("xxxxxxxx")).click();

when code execute the above line , click has been performed in the browser and a new page starts loading but code stuck at the above line untill the whole page loads. i am not able to perform any operation on any webelemnet untill the page loads completely. below is the code:

WebElement element = driver.findElement(By.xpath(".//*[@id='lll-menu-1']/div[1]/ul/li[4]/a"));

JavascriptExecutor executor = (JavascriptExecutor)driver;

executor.executeScript("arguments[0].click();", element);after this line code stuck here until the page loads completely

WebElement elem = driver.findElement(By.xpath(".//img[@alt='Cool Racerback - regular']"));

elem.click();

2
What have you tried and what was the result? As you did in school... please show your work. :) It's part of the process of getting questions answered on SO. It's helpful to you because it forces you to investigate your own problem and think it through. It also proves to readers that you did your homework and made a reasonable attempt to answer your own question. Thirdly, it helps readers find and diagnose the problem resulting in a better answer for you and less time wasted for us. - JeffC
hi JeffC i am performing a click on an element 'WebElement elem = driver.findElement(By.xpath(".//img[@alt='Cool Racerback - regular']")); elem.click(); after click() new page starts loading and my code stuck after click ,control is not navigated to the next instruction until the page loads completely. - Utkarsh Chaudhary
Please put this code and any other info into the original question so that it's easier to find and can be properly formatted. It will make your question more likely to be answered. - JeffC

2 Answers

0
votes

You can try with:

 WebDriverWait wait = new WebDriverWait(driver, 10);
 wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("YOUR ELEMENT XPATH")));
0
votes

I don't think it is possible, you have to just wait for the page to load as this is built into webdriver.