0

How to get request of a element by using selenium.

 public void TestFlightSubmit(){
        driver.findElement(By.className("primaryBtn font24 latoBlack widgetSearchBtn"));
    }

Is there any way so that I can get request of this element by passing its className and save it into my HAR file.

Failed to get all the Page View requests and Clicked Requests on the web application

I had coded a test case for Automation in Selenium to get all the requests on the web page including Clicked Elements. But I think I'm not able to get all the requests on my web page. Can anyone help me how can I get all requests especially Clicked Elements Requests.

My Code: @BeforeTest

public void setUp(){
    proxy = new BrowserMobProxyServer();
    proxy.start(3000);
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver");

    WebDriver driver = new ChromeDriver(capabilities);
    proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.REQUEST_BINARY_CONTENT, CaptureType.REQUEST_HEADERS, CaptureType.REQUEST_COOKIES);
    proxy.newHar("MakeMyTripSearchFlights");
    driver.get("https://www.makemytrip.com/");
}

@Test(expectedExceptions = { IOException.class })

public void TestFlightSubmit(){
    driver.findElement(By.className("primaryBtn font24 latoBlack widgetSearchBtn"));
}
Mikhail Zhuikov
  • 1,213
  • 2
  • 9
  • 19
  • 4
    Are you sure the code ran fine? Coz `By.className` doesn't support spaces. You'll get `Compound class names not permitted` error. – Madhan Jun 21 '19 at 12:34
  • Thank you Madhan But My main objective is to get Performance Data of the Element when we click on it. If you know anything please do share it will be very helpful. – Mohd Shahid Jun 24 '19 at 04:58

0 Answers0