In the https://store.liverpoolfc.com/ home page there is feedback button on right side, I managed to click and open feedback modal but cant get Id of rating button, I tried to add id, classname, xpath, csselector of input in feedback but its not working.
Here is my code:
By acceptCookies = By.id("onetrust-accept-btn-handler");
By feedbackHomeBtn = By.id("nebula_div_btn");
By feedbackBackBtn = By.xpath("//*[@id='wrapper_c59e-d4ab-ebe9-648a-b368-0624-c2bf-8d63']/div/neb-rating/div/form/span/span[10]/label");
By feedBackInput = By.name("rating");
public void acceptCookies(){
try{
driver.findElement(acceptCookies).click();
}catch(Exception e){
System.out.println("Exceptions Caught" e.getMessage());
}
}
public void feedbackFuncionality(){
try{
driver.findElement(feedbackHomeBtn).click();
driver.findElement(feedbackBackBtn).click();
driver.findElement(feedBackInput).click();
}catch(Exception e){
System.out.println("Exceptions Caught" e.getMessage());
}
}
And code in test.java
@BeforeTest
public void beforeTest(){
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(url);
}
@Test
public void sortItemsBySize() throws InterruptedException{
FeedBackPage feedBackPage = new FeedBackPage(driver);
feedBackPage.acceptCookies();
Thread.sleep(5000);
feedBackPage.feedbackFuncionality();
Thread.sleep(3000);
}
@AfterTest
public void afterTest(){
driver.quit();
}
I need to open feedback modal and click on rating btn between 1 and 10. Can anyone give me some hints how to get this id? Thanks
CodePudding user response:
You can get the rating button with css selector
By.cssSelector("input[value='x']")
where x = 0, 1, 2...
CodePudding user response:
You are trying to click on the element which is inside cross-origin iframe
You need to switch the frame and then click on the element
you can switch using following way
driver.switchTo().frame("Your_frame_ID");