Commit bcbb49ae authored by Qazi Zain's avatar Qazi Zain

ajax Call Hanndling code added in repo

parent 949460eb
package Handling_SSL_Certification_and_AJAXCalls;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class AjaxCall {
public static void main(String[] args) {
//---------------> here i am creating an object of firefox browser.
WebDriver obj = new FirefoxDriver();
//---------------------> Defining the Explicit time.
WebDriverWait wait = new WebDriverWait(obj, Duration.ofSeconds(5));
//-------> Fetch the link and open the web on browser of which object is created.
obj.get("http://omayo.blogspot.com/");
// creating javaScript Executor.
JavascriptExecutor js = (JavascriptExecutor)obj;
js.executeScript("window.scrollBy(0,1400)"); // for scroll web downwards.
js.executeScript("window.scrollBy(60,0)"); // for scroll web right side.
//---------------------------------------> (Finding the Locator of Dropdown Button) <-----------------------------------
//---> creating a button and storing a locator for maintainability of code.
WebElement DropdownButton = obj.findElement(By.cssSelector("button.dropbtn"));
DropdownButton.click();
WebElement FlipkartButton = obj.findElement(By.xpath("//div[@id='myDropdown']/a[2]"));
//--------------------------------------> Adding Explicit wait to handle ajax call.
wait.until(ExpectedConditions.visibilityOf(FlipkartButton));
FlipkartButton.click();
}
}
package Handling_SSL_Certification_and_AJAXCalls;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
public class SSLCertificate {
public static void main(String[] args) {
FirefoxOptions SSL = new FirefoxOptions();
SSL.setAcceptInsecureCerts(true);
WebDriver obj = new FirefoxDriver(SSL); // passing ssl object in parameter to bypass SSL Certification.
obj.get("https://expired.badssl.com/");
}
}
package JsExecutor;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class JsExecutor
{
public static void main(String[] args) {
WebDriver obj = new FirefoxDriver();
obj.get("https://rahulshettyacademy.com/AutomationPractice/");
// Creating JavaScript Executor Object.
JavascriptExecutor js = (JavascriptExecutor) obj; // casting obj as javascript executor to store in js object.
js.executeScript("window.scrollBy(0,700)");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment