Java selenium

0

Witam, chciałbym dodać do mojego kodu kolejny element do znalezienia i kliknięcia.
Na początku kiedy to zrobiłem i odpaliłem, wszystko działało jak powinno. Lecz kiedy dodałem do kodu aby otworzyła się kolejna strona, program zatrzymał się na 1 elemencie wyszukiwania i kliknięcia. Po usunięciu z kodu odpalenia nowej strony, problem nadal występuje.
Mój kod( bez

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class bot12 {
	public static void main(String[] args) {
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\macie\\eclipse-workspace\\bot v12\\lib\\chromedriver.exe");
		WebDriver driver=new ChromeDriver();
		driver.navigate().to("https://www.supremenewyork.com/shop/all/sweatshirts/");
		driver.findElement(By.partialLinkText("Jewels Hooded Sweatshirt")).click();
		driver.findElement(By.name("commit")).click();
		driver.navigate().to("https://www.supremenewyork.com/checkout/");		
	}
	    

}

Dodatkowo w konsoli wyskakuje takie coś:
*** Element info: {Using=name, value=commit}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:449)
at org.openqa.selenium.By$ByName.findElement(By.java:303)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at bot12.main(bot12.java:11)

0

Z tego co widać, to na tej swojej pierwszej stronce, nie masz elementu o nazwie commit

0

"commit" miał być wyszukany na stronie wywołanej po naciśnięciu na link "Jewels Hooded Sweatshirt". Na początku tak się właśnie stało A dlaczego teraz nie działa to już nie wiem .

0

Z tego co widze ta strona to takie troche SPA, wiec elementy laduja sie dynamicznie. Po kliknieciu w ta bluze, strona przez pewien czas sie laduje.
Sprobuj dodac jakiegos FluentWait'a albo cos co poczeka az ten element "commit" bedzie faktycznie widoczny i wtedy dopiero click.
Selenium chyba samo z siebie nie ma wbudowanych zadnych implicit wait'ow tak jak to robi Selenide.

0

Dodałem FluentWait, ale nadal wyskakuje ten sam błąd

Mój kod;

import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;

public class v21 { 
	public static void main(String[] args) {
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\macie\\eclipse-workspace\\bot v12\\lib\\chromedriver.exe");
		WebDriver driver=new ChromeDriver();
		driver.navigate().to("https://www.supremenewyork.com/shop/all/pants/");
		driver.findElement(By.linkText("Coveralls")).click();
		
		   Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
		       .withTimeout(20, TimeUnit.SECONDS)
		       .pollingEvery(2, TimeUnit.SECONDS)
		       .ignoring(NoSuchElementException.class);

		   WebElement element = wait.until(new Function<WebDriver, WebElement>() {
		     public WebElement apply(WebDriver driver) {
		     return  driver.findElement(By.name("commit"));
		     
		       
		           
		     } 
		   });
		   
		   } 


0

Ktoś coś?

1 użytkowników online, w tym zalogowanych: 0, gości: 1