Issue
I have this website: https://magiceden.io/marketplace/primates. On the website there's a default option of "Recently listed". How can I use java selenium to change that from the checklist to "price: low to high"?
Solution
This is quite simple and can be done simply using the native driver properties without over complicating it with using Javascript, Actions or Scroll.
You are facing a problem because the element you are trying to locate is called an "svg element" so it will not support standard xpath format. So rather than focusing on the checkbox, pin-point the non svg element instead (the div class the element is in).
The code will then look like this:
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
class App {
public static WebDriver driver;
public static void main(String[] args) {
// set your driver here
...
// select checkbox
driver.get("https://magiceden.io/marketplace/primates");
driver.findElement(By.xpath("//input[@value='Recently Listed']")).click();
driver.findElement(By.xpath("//div[normalize-space()='Price: Low to high']")).click();
}
}
The final result will look like this:
[
Answered By - Gautam Nag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.